webpack-resolve-path-rewrite-plugin

1.0.4 • Public • Published

webpack-resolve-path-rewrite-plugin

A plugin for enhanced-resolve (Webpack v2) that replaces specified string inside the path.

Installation

npm install --save-dev webpack-resolve-path-rewrite-plugin

Usage

var path = require('path');
var PathRewrite = require('webpack-resolve-path-rewrite-plugin');
 
module.exports = {
  // ...
  resolve: {
    plugins: [
      new PathRewritePlugin({pathMap: {
        '/module/': '/../../CommonEngine/src/module/'
      }})
    ]
  },
  // ...
};
 

Example:

webpack.config.js

new PathRewritePlugin({pathMap: {
  '/module/': '/../../CommonEngine/src/module/'
}})

actions/sendForm.js

import 'src/module/index' // Changes to 'src/../../CommonEngine/src/module/index'

Why

Why rewrite paths?

When:

  1. Multiple entrypoints require a common module inside their directory (i.e. submodule)
  2. You want to use CommonsChunkPlugin

Change log

1.0.1

Solved bugs.

1.0.0

Initial release.

Package Sidebar

Install

npm i webpack-resolve-path-rewrite-plugin

Weekly Downloads

1

Version

1.0.4

License

MIT

Unpacked Size

3.87 kB

Total Files

5

Last publish

Collaborators

  • squaresun