Merge pull request #6152 from open-sausages/pulls/4.0/webpack-dev-optimize

Added development watch command to package.json
This commit is contained in:
Damian Mooyman 2016-10-13 17:50:53 +13:00 committed by GitHub
commit 4bbfb7e4f2
3 changed files with 29 additions and 4 deletions

View File

@ -11,6 +11,7 @@
},
"scripts": {
"build": "webpack",
"watch": "webpack --config ./webpack-dev.config.js --watch",
"css": "WEBPACK_CHILD=css webpack",
"lock": "npm-shrinkwrap --dev",
"test": "NODE_PATH=\"./client/src:./admin/client/src\" jest",

25
webpack-dev.config.js Normal file
View File

@ -0,0 +1,25 @@
const webpack = require('webpack');
const Config = require('./webpack.config');
if (Array.isArray(Config)) {
const jsConfig = Config.find((item) => item.name === 'js');
jsConfig.plugins = [
new webpack.ProvidePlugin({
jQuery: 'jQuery',
$: 'jQuery',
}),
// Most vendor libs are loaded directly into the 'vendor' bundle (through require() calls in vendor.js).
// This ensures that any further require() calls in other bundles aren't duplicating libs.
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity,
}),
];
for (var i = 0; i < Config.length; i++) {
Config[i].devtool = 'source-map';
}
}
module.exports = Config;

View File

@ -1,6 +1,7 @@
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');
// const SprityWebpackPlugin = require('sprity-webpack-plugin');
const PATHS = {
@ -48,7 +49,8 @@ const config = [
TinyMCE_SSPlugin: `${PATHS.ADMIN_JS_SRC}/legacy/TinyMCE_SSPlugin.js`,
},
resolve: {
modulesDirectories: [PATHS.ADMIN_JS_SRC, PATHS.MODULES],
root: [__dirname, path.resolve(__dirname, PATHS.ADMIN_JS_SRC)],
modulesDirectories: [PATHS.MODULES],
},
output: {
path: 'admin/client/dist',
@ -88,7 +90,6 @@ const config = [
config: 'Config',
'lib/Router': 'Router',
},
devtool: 'source-map',
module: {
loaders: [
{
@ -152,7 +153,6 @@ const config = [
path: 'admin/client/dist',
filename: '[name].css',
},
devtool: 'source-map',
module: {
loaders: [
{
@ -202,7 +202,6 @@ const config = [
path: './',
filename: '[name].css',
},
devtool: 'source-map',
module: {
loaders: [
{