Closed jchip closed 7 years ago
@jchip Fot instance, if you have the following npm
script:
"scripts": {
"start": "NODE_ENV=development webpack-dev-server --config webpack.config.js --progress --port 3000 --https --hot --inline --compress",
"build": "NODE_ENV=production webpack --config webpack.config.js --hide-modules"
},
and the following webpack config:
webpack.config.js
const WebpackConfig = require('webpack-config');
module.exports = new WebpackConfig().extend('./webpack.[NODE_ENV].config.js');
If you run npm run start
then webpack.development.config.js
will be included into webpack.config.js
.
If you run npm run build
then webpack.production.config.js
will be included into webpack.config.js
.
Also you may use environment
map of webpack-config
to do the same:
const WebpackConfig = require('webpack-config');
const environment = require('webpack-config'). environment;
environment.setAll({
'env': process.env. NODE_ENV
});
module.exports = new WebpackConfig().extend('./webpack.[env].config.js');
In both cases [NODE_ENV]
and [env]
will be automatically interpolated.
Also if you have any strings which contain [NODE_ENV]
or [env]
then they also should be interpolated:
const WebpackConfig = require('webpack-config');
const environment = require('webpack-config'). environment;
environment.setAll({
env: 'bar'
});
const webpackConfig = new WebpackConfig();
webpackConfig.merge({
foo: 'env'
});
console.log(webpackConfig.toObject()); // => { foo: 'bar' }
Variable aka environment interpolations is designed for extend
method, but you may use it for defaults
and merge
.
For more info please see:
https://github.com/Fitbit/webpack-config/blob/master/test/ConfigStringResolver.spec.js https://github.com/Fitbit/webpack-config/blob/master/test/ConfigEnvironment.spec.js
Thank you for such a thorough answer!
@jchip May I close this issue?
@jchip Do you have any additional questions?
I am trying to find out more info about these two features:
I see that in the readme there's
Is there more info somewhere else?