Skip to content

Commit 5cad839

Browse files
authored
Merge pull request #172 from Lyrkan/fix-define-plugin-development
Add an instance of DefinePlugin even in development mode
2 parents 929a253 + ee511dc commit 5cad839

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

lib/plugins/define.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,9 @@ const webpack = require('webpack');
1717
* @return {void}
1818
*/
1919
module.exports = function(plugins, webpackConfig) {
20-
21-
if (!webpackConfig.isProduction()) {
22-
return;
23-
}
24-
2520
const definePluginOptions = {
2621
'process.env': {
27-
NODE_ENV: '"production"'
22+
NODE_ENV: webpackConfig.isProduction() ? '"production"' : '"development"'
2823
}
2924
};
3025

test/plugins/define.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ describe('plugins/define', () => {
3030
const plugins = [];
3131

3232
definePluginUtil(plugins, config);
33-
expect(plugins.length).to.equal(0);
33+
expect(plugins.length).to.equal(1);
34+
expect(plugins[0]).to.be.instanceof(webpack.DefinePlugin);
35+
expect(plugins[0].definitions['process.env'].NODE_ENV).to.equal(JSON.stringify('development'));
3436
});
3537

3638
it('production environment with default settings', () => {
@@ -40,6 +42,7 @@ describe('plugins/define', () => {
4042
definePluginUtil(plugins, config);
4143
expect(plugins.length).to.equal(1);
4244
expect(plugins[0]).to.be.instanceof(webpack.DefinePlugin);
45+
expect(plugins[0].definitions['process.env'].NODE_ENV).to.equal(JSON.stringify('production'));
4346
});
4447

4548
it('production environment with options callback', () => {

0 commit comments

Comments
 (0)