Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cvgellhorn/path-replace-loader
Path replace loader for webpack
https://github.com/cvgellhorn/path-replace-loader
babel loader path replace webpack webpack2 webpack3
Last synced: about 1 month ago
JSON representation
Path replace loader for webpack
- Host: GitHub
- URL: https://github.com/cvgellhorn/path-replace-loader
- Owner: cvgellhorn
- License: mit
- Archived: true
- Created: 2016-04-09T21:29:32.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-08T14:51:50.000Z (about 7 years ago)
- Last Synced: 2024-09-24T20:03:58.375Z (about 1 month ago)
- Topics: babel, loader, path, replace, webpack, webpack2, webpack3
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 14
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# path-replace-loader for webpack
Path replace loader for [webpack](https://webpack.js.org/). Replace a given base path with another path for dynamic module loading. Great for large applications with locally overridable modules.
## Installation
`$ npm install path-replace-loader`
## Usage
[Read more about using loaders](https://webpack.js.org/configuration/module/#module-rules)
#### Configuration
- path: Absolute original path to replace, e.g. __dirname/app/core
- replacePath: Absolute replacement path, e.g. __dirname/app/local#### webpack config
``` js
module.exports = {
module: {
rules: [
{
test: /\.js$/,
loader: 'path-replace-loader',
exclude: /(node_modules)/,
options: {
path: 'ORIGINAL_PATH',
replacePath: 'REPLACE_PATH'
}
}
]
}
};
```#### Example
Loader tries to load from local directory if file exists app/local/modules/auth
``` js
const authModule = require('app/core/modules/auth');
```#### Babel + webpack
Make sure to include this in your .babelrc, if you want to use Babel with webpack
``` js
{
"presets": [
["es2015", { "modules": false }]
]
}
```## Release History
- 2.0.0 - Bump packages and add webpack 3 support
- 1.0.0 - Add webpack 2 support
- 0.2.2 - Improve example
- 0.2.1 - Update README
- 0.2.0 - Use dependency to introduce file to webpack in order to make them watchable
- 0.1.0 - Initial release### [MIT License](http://www.opensource.org/licenses/mit-license.php)