remove env variable in npm scrpts; rename watch script for clarity
This commit is contained in:
@@ -20,7 +20,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build:production": "webpack -p",
|
"build:production": "webpack -p",
|
||||||
"build": "webpack -d",
|
"build": "webpack -d",
|
||||||
"watch": "NODE_ENV=development node dev.js"
|
"watch": "node watch.js"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.12.0",
|
"node": ">= 0.12.0",
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
/* eslint no-console: 0 */
|
/* eslint no-console: 0 */
|
||||||
|
|
||||||
|
process.env.SCRIPT = 'watch';
|
||||||
|
|
||||||
var webpack = require('webpack'),
|
var webpack = require('webpack'),
|
||||||
webpackDevMiddleware = require('webpack-dev-middleware'),
|
webpackDevMiddleware = require('webpack-dev-middleware'),
|
||||||
webpackHotMiddleware = require('webpack-hot-middleware'),
|
webpackHotMiddleware = require('webpack-hot-middleware'),
|
||||||
@@ -137,7 +137,7 @@ webpackConfig = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (process.argv.lastIndexOf('-d') !== -1 ||
|
if (process.argv.lastIndexOf('-d') !== -1 ||
|
||||||
process.env.NODE_ENV === 'development') {
|
process.env.SCRIPT === 'watch') {
|
||||||
// development
|
// development
|
||||||
webpackConfig.output.filename = 'scripts/[name].js';
|
webpackConfig.output.filename = 'scripts/[name].js';
|
||||||
webpackConfig.plugins.push(new webpack.optimize.OccurenceOrderPlugin());
|
webpackConfig.plugins.push(new webpack.optimize.OccurenceOrderPlugin());
|
||||||
@@ -145,7 +145,7 @@ if (process.argv.lastIndexOf('-d') !== -1 ||
|
|||||||
webpackConfig.plugins.push(new webpack.NoErrorsPlugin());
|
webpackConfig.plugins.push(new webpack.NoErrorsPlugin());
|
||||||
webpackConfig.plugins.push(new ExtractTextPlugin('styles/[name].css', {
|
webpackConfig.plugins.push(new ExtractTextPlugin('styles/[name].css', {
|
||||||
// disable if webpack is called from the node.js api or set to false in config file
|
// disable if webpack is called from the node.js api or set to false in config file
|
||||||
disable: (process.env.NODE_ENV === 'development' || config.options.extractStyles === false)
|
disable: (process.env.SCRIPT === 'watch' || config.options.extractStyles === false)
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
// default or production
|
// default or production
|
||||||
@@ -159,8 +159,7 @@ if (process.argv.lastIndexOf('-d') !== -1 ||
|
|||||||
canPrint: true
|
canPrint: true
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
if (process.env.SCRIPT === 'watch') {
|
||||||
if (process.env.NODE_ENV === 'development') {
|
|
||||||
// development settings when called from the node.js api by the watch script
|
// development settings when called from the node.js api by the watch script
|
||||||
webpackConfig.entry = addHotMiddleware(webpackConfig.entry);
|
webpackConfig.entry = addHotMiddleware(webpackConfig.entry);
|
||||||
webpackConfig.output.pathinfo = true;
|
webpackConfig.output.pathinfo = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user