1.0.0 • Published 8 years ago

path-replace-plus-loader v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

path-replace-plus-loader for webpack

Path replace loader(plus) for webpack. Replace a or some given base path with another path for dynamic module loading. Great for large applications with locally overridable modules.

Installation

npm install path-replace-plus-loader

Usage

Read more about using loaders

Configuration

  • list: An array of replace rules

The rules must be like:

  • path: Absolute original path to replace, e.g. __dirname/app/core
  • replacePath: Absolute replacement path, e.g. __dirname/app/local

webpack config example

module.exports = {
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'path-replace-plus',
        query: {
          list: [{
            path: 'ORIGINAL_PATH 1',
            replacePath: 'REPLACE_PATH 1'
          },{
            path: 'ORIGINAL_PATH 2',
            replacePath: 'REPLACE_PATH 2'
          }]
        }
      }
    ]
  }
};

Example

// Loader tries to load from local directory if file exists app/local/modules/auth
var authModule = require('app/core/modules/auth');

MIT License