Merge "Upgrade to webpack 4"

This commit is contained in:
Zuul 2018-04-10 20:09:54 +00:00 committed by Gerrit Code Review
commit 09ca487406
6 changed files with 1956 additions and 770 deletions

View File

@ -38,23 +38,24 @@
"babel-plugin-angularjs-annotate": "^0.8.2", "babel-plugin-angularjs-annotate": "^0.8.2",
"babel-preset-env": "^1.6.1", "babel-preset-env": "^1.6.1",
"clean-webpack-plugin": "^0.1.16", "clean-webpack-plugin": "^0.1.16",
"css-loader": "^0.28.4", "css-loader": "^0.28.10",
"eslint": ">=3.19.0", "eslint": ">=3.19.0",
"eslint-config-standard": "^11.0.0-beta.0", "eslint-config-standard": "^11.0.0-beta.0",
"eslint-loader": "^1.9.0", "eslint-loader": "^2.0.0",
"eslint-plugin-import": "^2.8.0", "eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^6.0.0", "eslint-plugin-node": "^6.0.0",
"eslint-plugin-promise": "^3.6.0", "eslint-plugin-promise": "^3.6.0",
"eslint-plugin-standard": "^3.0.1", "eslint-plugin-standard": "^3.0.1",
"file-loader": "^0.11.2", "file-loader": "^1.1.11",
"html-webpack-plugin": "^2.29.0", "html-webpack-plugin": "^3.0.0",
"resolve-url-loader": "^2.1.0", "resolve-url-loader": "^2.1.0",
"style-loader": "^0.18.2", "style-loader": "^0.20.3",
"url-loader": "^0.5.9", "url-loader": "^0.5.9",
"webpack": "^3.3.0", "webpack": "^4.4.0",
"webpack-archive-plugin": "^3.0.0", "webpack-archive-plugin": "^3.0.0",
"webpack-bundle-analyzer": "^2.9.1", "webpack-bundle-analyzer": "^2.9.1",
"webpack-dev-server": "^2.6.1", "webpack-cli": "^2.0.11",
"webpack-dev-server": "^3.0.0",
"webpack-merge": "^4.1.0" "webpack-merge": "^4.1.0"
} }
} }

View File

@ -1,20 +1,9 @@
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = { module.exports = {
entry: { entry: './web/main.js',
main: './web/main.js',
// Tell webpack to extract 3rd party depdenencies which change less
// frequently.
vendor: [
'angular',
'bootstrap/dist/css/bootstrap.css',
'jquery-visibility/jquery-visibility',
'graphitejs/jquery.graphite.js'
]
},
output: { output: {
filename: '[name].js', filename: '[name].js',
// path.resolve(__dirname winds up relative to the config dir // path.resolve(__dirname winds up relative to the config dir
@ -25,19 +14,23 @@ module.exports = {
// expensive to build for prod. Debugging without the full source-map sucks, // expensive to build for prod. Debugging without the full source-map sucks,
// so define it here in common. // so define it here in common.
devtool: 'source-map', devtool: 'source-map',
optimization: {
runtimeChunk: true,
splitChunks: {
cacheGroups: {
commons: {
test: /node_modules/,
name: "vendor",
chunks: "all"
}
}
}
},
plugins: [ plugins: [
new webpack.ProvidePlugin({ new webpack.ProvidePlugin({
$: 'jquery/dist/jquery', $: 'jquery/dist/jquery',
jQuery: 'jquery/dist/jquery', jQuery: 'jquery/dist/jquery',
}), }),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
}),
new CleanWebpackPlugin(
['zuul/web/static'], { root: path.resolve(__dirname, '../..')}),
// Each of the entries below lists a specific 'chunk' which is one of the // Each of the entries below lists a specific 'chunk' which is one of the
// entry items from above. We can collapse this to just do one single // entry items from above. We can collapse this to just do one single
// output file. // output file.

View File

@ -4,7 +4,7 @@ const Merge = require('webpack-merge');
const CommonConfig = require('./webpack.common.js'); const CommonConfig = require('./webpack.common.js');
module.exports = Merge(CommonConfig, { module.exports = Merge(CommonConfig, {
mode: 'development',
// Enable Hot Module Replacement for devServer // Enable Hot Module Replacement for devServer
devServer: { devServer: {
hot: true, hot: true,

View File

@ -5,7 +5,7 @@ const CommonConfig = require('./webpack.common.js');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = Merge(CommonConfig, { module.exports = Merge(CommonConfig, {
mode: 'development',
module: { module: {
rules: [ rules: [
{ {

View File

@ -2,42 +2,25 @@ const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const Merge = require('webpack-merge'); const Merge = require('webpack-merge');
const CommonConfig = require('./webpack.common.js'); const CommonConfig = require('./webpack.common.js');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ArchivePlugin = require('webpack-archive-plugin'); const ArchivePlugin = require('webpack-archive-plugin');
module.exports = Merge(CommonConfig, { module.exports = Merge(CommonConfig, {
mode: 'production',
output: { output: {
filename: '[name].[chunkhash].js', filename: '[name].[chunkhash].js',
// path.resolve(__dirname winds up relative to the config dir // path.resolve(__dirname winds up relative to the config dir
path: path.resolve(__dirname, '../../zuul/web/static'), path: path.resolve(__dirname, '../../zuul/web/static'),
publicPath: '' publicPath: ''
}, },
optimization: {
minimize: true
},
plugins: [ plugins: [
new webpack.LoaderOptionsPlugin({ new CleanWebpackPlugin(
minimize: true, ['zuul/web/static'], { root: path.resolve(__dirname, '../..')}),
debug: false
}),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
// Keeps the vendor bundle from changing needlessly. // Keeps the vendor bundle from changing needlessly.
new webpack.HashedModuleIdsPlugin(), new webpack.HashedModuleIdsPlugin(),
new webpack.optimize.UglifyJsPlugin({
warningsFilter: function(filename) {
return ! /node_modules/.test(filename);
},
beautify: false,
mangle: {
screw_ie8: true,
keep_fnames: true
},
compress: {
screw_ie8: true
},
sourceMap: true,
comments: false
}),
new ArchivePlugin({ new ArchivePlugin({
output: path.resolve(__dirname, '../../zuul-web'), output: path.resolve(__dirname, '../../zuul-web'),
format: [ format: [

2643
yarn.lock

File diff suppressed because it is too large Load Diff