Replace file [name].[ext] with [name].[key].[ext];
$ npm install webpack-replace-module-loader --save-dev
- src/config.json
- src/config.test.json
- src/config.production.json
module: {
loaders: [{
test: [/config\.json$/],
loader: 'webpack-replace-module-loader',
include: [path.join(__dirname, 'src')],
query: { key: process.env.BUILD_ENV }
}]
}
$ BUILD_ENV=production webpack
- The value add to the file name. The replace file is [name].[key].[ext]