2.0.0 • Published 6 years ago
inject-webpack-plugin v2.0.0
webpack Dependency Injection Plugin
A simple webpack plugin for injecting dependencies.
Installation
Install the plugin with npm:
$ npm install inject-webpack-plugin --save-dev
Basic Usage
In your webpack.config.js
import InjectWebpackPlugin from 'webpack-inject-plugin';
export default {
// ...
plugins: [
new InjectWebpackPlugin({
'path/to/file': 'path/to/another/file',
'path/to/file.scss': 'path/to/another/file.scss',
'react': 'replacing/react/like/a/boss'
});
]
};
This will replace any instances of path/to/file
with path/to/another/file
, path/to/file.scss
with path/to/another/file.scss
, as well as allowing you to replace react
if you so wish.
Useful for getting around things like this by combining with environment variables. For example:
if (process.env.NODE_ENV === 'development') {
plugins.push(
new InjectWebpackPlugin({
'configureStore': 'configureStore.dev'
});
)
}