Skip to content

tnulc/inject-webpack-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'
    });
  )
}