1.0.1 • Published 9 years ago

prepost-loader v1.0.1

Weekly downloads
5
License
MIT
Repository
-
Last release
9 years ago

prepost loader for webpack

A loader add prefix or postfix string to source file for webpack. based on imports-loader

Installation

npm install prepost-loader

Usage Examples

  1. Auto import React and React.Component for all .jsx files.

    // ./webpack.config.js
    
    module.exports = {
        ...
        module: {
            loaders: [
                {
                    test: /\.jsx$/,
                    loader: "prepost",
                    query: {
                      prefix: ['var React = require("react");', 'var Component = React.Component;'],
                      postfix: ''
                    }
                }
            ]
      };
  1. If you have tow files: /path/to/foo.jsx and /path/to/foo.sass. Every time you require foo.jsx, you want auto require foo.sass, then you can write something like this in webpack config file.

    // ./webpack.config.js
    
    module.exports = {
        ...
        module: {
            loaders: [
                {
                    test: /\.jsx$/,
                    loader: "prepost",
                    query: {
                      autoRequireExtensions: ['sass', 'scss', 'css']
                    }
                }
            ]
      };

Documentation: Using loaders

License

MIT