remove env variable in npm scrpts; rename watch script for clarity

This commit is contained in:
Patrick Vézina
2016-03-15 22:14:04 -04:00
parent 8e2aeb53ab
commit 9bb62336a8
3 changed files with 6 additions and 5 deletions

View File

@@ -20,7 +20,7 @@
"scripts": {
"build:production": "webpack -p",
"build": "webpack -d",
"watch": "NODE_ENV=development node dev.js"
"watch": "node watch.js"
},
"engines": {
"node": ">= 0.12.0",

View File

@@ -1,5 +1,7 @@
/* eslint no-console: 0 */
process.env.SCRIPT = 'watch';
var webpack = require('webpack'),
webpackDevMiddleware = require('webpack-dev-middleware'),
webpackHotMiddleware = require('webpack-hot-middleware'),

View File

@@ -137,7 +137,7 @@ webpackConfig = {
};
if (process.argv.lastIndexOf('-d') !== -1 ||
process.env.NODE_ENV === 'development') {
process.env.SCRIPT === 'watch') {
// development
webpackConfig.output.filename = 'scripts/[name].js';
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 ExtractTextPlugin('styles/[name].css', {
// 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 {
// default or production
@@ -159,8 +159,7 @@ if (process.argv.lastIndexOf('-d') !== -1 ||
canPrint: true
}));
}
if (process.env.NODE_ENV === 'development') {
if (process.env.SCRIPT === 'watch') {
// development settings when called from the node.js api by the watch script
webpackConfig.entry = addHotMiddleware(webpackConfig.entry);
webpackConfig.output.pathinfo = true;