Update prod config to Webpack 4 api
parent
640fdbe0c5
commit
6080ee867b
|
@ -9,7 +9,7 @@
|
|||
"url": "github:influxdata/chronograf"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn run clean && webpack --config ./webpack/prod.config.js --display-error-details",
|
||||
"build": "yarn run clean && webpack --config ./webpack/prod.config.js",
|
||||
"build:dev": "webpack --config ./webpack/dev.config.js",
|
||||
"build:vendor": "webpack --config webpack/vendor.config.js",
|
||||
"start": "yarn run clean && yarn run build:vendor && webpack --watch --config ./webpack/dev.config.js",
|
||||
|
@ -54,7 +54,7 @@
|
|||
"autoprefixer": "^6.3.1",
|
||||
"babel-core": "^6.5.1",
|
||||
"babel-eslint": "6.1.2",
|
||||
"babel-loader": "^7.1.2",
|
||||
"babel-loader": "^7.1.4",
|
||||
"babel-plugin-lodash": "^2.0.1",
|
||||
"babel-plugin-syntax-trailing-function-commas": "^6.5.0",
|
||||
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
||||
|
@ -66,7 +66,6 @@
|
|||
"babel-preset-react": "^6.5.0",
|
||||
"babel-preset-stage-0": "^6.16.0",
|
||||
"babel-runtime": "^6.5.0",
|
||||
"compression-webpack-plugin": "^1.1.8",
|
||||
"concurrently": "^3.5.0",
|
||||
"core-js": "^2.1.3",
|
||||
"css-loader": "^0.28.11",
|
||||
|
@ -80,8 +79,7 @@
|
|||
"eslint-plugin-react": "6.6.0",
|
||||
"eslint-watch": "^3.1.2",
|
||||
"express": "^4.14.0",
|
||||
"extract-text-webpack-plugin": "^3.0.2",
|
||||
"file-loader": "^1.1.7",
|
||||
"file-loader": "^1.1.11",
|
||||
"fork-ts-checker-webpack-plugin": "^0.4.2",
|
||||
"hanson": "^1.1.1",
|
||||
"html-webpack-include-assets-plugin": "^1.0.2",
|
||||
|
@ -94,6 +92,7 @@
|
|||
"json-loader": "^0.5.7",
|
||||
"mini-css-extract-plugin": "^0.4.0",
|
||||
"node-sass": "^4.5.3",
|
||||
"optimize-css-assets-webpack-plugin": "^4.0.2",
|
||||
"postcss-browser-reporter": "^0.4.0",
|
||||
"postcss-calc": "^5.2.0",
|
||||
"postcss-loader": "^2.1.5",
|
||||
|
@ -114,7 +113,7 @@
|
|||
"tslint-plugin-prettier": "^1.3.0",
|
||||
"tslint-react": "^3.5.1",
|
||||
"typescript": "^2.7.2",
|
||||
"uglifyjs-webpack-plugin": "^1.2.2",
|
||||
"uglifyjs-webpack-plugin": "^1.2.5",
|
||||
"webpack": "^4.12.0",
|
||||
"webpack-bundle-analyzer": "^2.10.1",
|
||||
"webpack-cli": "^3.0.3",
|
||||
|
|
|
@ -33,7 +33,6 @@ const stats = {
|
|||
children: false,
|
||||
modules: false,
|
||||
version: false,
|
||||
warnings: false,
|
||||
assetsSort: '!size',
|
||||
excludeAssets: [/\.(hot-update|woff|eot|ttf|svg|ico|png)/],
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
/* eslint-disable no-var */
|
||||
const webpack = require('webpack')
|
||||
const path = require('path')
|
||||
const ExtractTextPlugin = require('extract-text-webpack-plugin')
|
||||
const get = require('lodash/get')
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
|
||||
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
|
||||
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
|
||||
const ProgressBarPlugin = require('progress-bar-webpack-plugin')
|
||||
|
||||
const pkg = require('../package.json')
|
||||
const dependencies = pkg.dependencies
|
||||
|
@ -19,6 +21,26 @@ const babelLoader = {
|
|||
}
|
||||
|
||||
const config = {
|
||||
mode: 'production',
|
||||
stats: 'errors-only',
|
||||
optimization: {
|
||||
concatenateModules: true,
|
||||
splitChunks: {
|
||||
name: 'vendor',
|
||||
minChunks: 2,
|
||||
},
|
||||
minimizer: [
|
||||
new UglifyJsPlugin({
|
||||
cache: true,
|
||||
parallel: true,
|
||||
sourceMap: true, // set to true if you want JS source maps
|
||||
uglifyOptions: {
|
||||
ie8: false,
|
||||
},
|
||||
}),
|
||||
new OptimizeCSSAssetsPlugin({}),
|
||||
],
|
||||
},
|
||||
node: {
|
||||
fs: 'empty',
|
||||
module: 'empty',
|
||||
|
@ -54,7 +76,7 @@ const config = {
|
|||
'memoizerific.js'
|
||||
),
|
||||
],
|
||||
loaders: [
|
||||
rules: [
|
||||
{
|
||||
test: /\.ts(x?)$/,
|
||||
exclude: /node_modules/,
|
||||
|
@ -72,23 +94,14 @@ const config = {
|
|||
enforce: 'pre',
|
||||
},
|
||||
{
|
||||
test: /\.scss$/,
|
||||
loader: ExtractTextPlugin.extract({
|
||||
fallback: 'style-loader',
|
||||
use: [
|
||||
'css-loader',
|
||||
'sass-loader',
|
||||
'resolve-url-loader',
|
||||
'sass-loader?sourceMap',
|
||||
],
|
||||
}),
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
loader: ExtractTextPlugin.extract({
|
||||
fallback: 'style-loader',
|
||||
use: ['css-loader', 'postcss-loader'],
|
||||
}),
|
||||
test: /\.(sa|sc|c)ss$/,
|
||||
use: [
|
||||
MiniCssExtractPlugin.loader,
|
||||
'css-loader',
|
||||
'sass-loader',
|
||||
'resolve-url-loader',
|
||||
'sass-loader?sourceMap',
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.(ico|png|cur|jpg|ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
|
||||
|
@ -124,9 +137,7 @@ const config = {
|
|||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
VERSION: JSON.stringify(require('../package.json').version),
|
||||
'process.env.NODE_ENV': JSON.stringify('production'),
|
||||
}),
|
||||
new webpack.optimize.ModuleConcatenationPlugin(),
|
||||
new ForkTsCheckerWebpackPlugin({
|
||||
checkSyntacticErrors: true,
|
||||
}),
|
||||
|
@ -139,25 +150,9 @@ const config = {
|
|||
},
|
||||
},
|
||||
}),
|
||||
new webpack.ProvidePlugin({
|
||||
$: 'jquery',
|
||||
jQuery: 'jquery',
|
||||
}),
|
||||
new ExtractTextPlugin('chronograf.css'),
|
||||
new UglifyJsPlugin({
|
||||
parallel: true,
|
||||
uglifyOptions: {
|
||||
ie8: false,
|
||||
},
|
||||
}),
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: 'vendor',
|
||||
minChunks(module) {
|
||||
return module.context && module.context.indexOf('node_modules') >= 0
|
||||
},
|
||||
}),
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: 'manifest',
|
||||
new MiniCssExtractPlugin({
|
||||
filename: 'chronograf.[chunkhash].css',
|
||||
chunkFilename: '[id].css',
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
template: path.resolve(__dirname, '..', 'src', 'index.template.html'),
|
||||
|
@ -165,17 +160,20 @@ const config = {
|
|||
chunksSortMode: 'dependency',
|
||||
favicon: 'assets/images/favicon.ico',
|
||||
}),
|
||||
function() {
|
||||
/* Webpack does not exit with non-zero status if error. */
|
||||
this.plugin('done', function(stats) {
|
||||
const {compilation: {errors}} = stats
|
||||
{
|
||||
apply: compiler => {
|
||||
compiler.hooks.afterEmit.tap('AfterEmitPlugin', ({compilation}) => {
|
||||
/* Webpack does not exit with non-zero status if error. */
|
||||
const errors = get(compilation, 'errors', [])
|
||||
|
||||
if (errors && errors.length) {
|
||||
errors.forEach(err => console.error(err))
|
||||
process.exit(1)
|
||||
}
|
||||
})
|
||||
if (errors.length) {
|
||||
errors.forEach(err => console.error(err))
|
||||
process.exit(1)
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
new ProgressBarPlugin(),
|
||||
],
|
||||
target: 'web',
|
||||
}
|
||||
|
|
|
@ -4,8 +4,18 @@ const packages = require('../package.json')
|
|||
const dependencies = packages.dependencies
|
||||
const ProgressBarPlugin = require('progress-bar-webpack-plugin')
|
||||
|
||||
const stats = {
|
||||
colors: true,
|
||||
children: false,
|
||||
modules: false,
|
||||
version: false,
|
||||
warnings: false,
|
||||
assetsSort: '!size',
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
mode: 'development',
|
||||
stats,
|
||||
node: {
|
||||
fs: 'empty',
|
||||
module: 'empty',
|
||||
|
|
51
ui/yarn.lock
51
ui/yarn.lock
|
@ -341,7 +341,7 @@ ajv@^4.7.0:
|
|||
co "^4.6.0"
|
||||
json-stable-stringify "^1.0.1"
|
||||
|
||||
ajv@^5.0.0, ajv@^5.1.0, ajv@^5.2.3, ajv@^5.3.0:
|
||||
ajv@^5.1.0, ajv@^5.2.3, ajv@^5.3.0:
|
||||
version "5.5.2"
|
||||
resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965"
|
||||
dependencies:
|
||||
|
@ -587,7 +587,7 @@ async@^1.4.0, async@^1.5.2:
|
|||
version "1.5.2"
|
||||
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
|
||||
|
||||
async@^2.1.4, async@^2.3.0, async@^2.4.1:
|
||||
async@^2.1.4, async@^2.3.0:
|
||||
version "2.6.0"
|
||||
resolved "https://registry.yarnpkg.com/async/-/async-2.6.0.tgz#61a29abb6fcc026fea77e56d1c6ec53a795951f4"
|
||||
dependencies:
|
||||
|
@ -851,7 +851,7 @@ babel-jest@^23.0.1:
|
|||
babel-plugin-istanbul "^4.1.6"
|
||||
babel-preset-jest "^23.0.1"
|
||||
|
||||
babel-loader@^7.1.2:
|
||||
babel-loader@^7.1.4:
|
||||
version "7.1.4"
|
||||
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.1.4.tgz#e3463938bd4e6d55d1c174c5485d406a188ed015"
|
||||
dependencies:
|
||||
|
@ -1733,7 +1733,7 @@ bytes@3.0.0:
|
|||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048"
|
||||
|
||||
cacache@^10.0.1, cacache@^10.0.4:
|
||||
cacache@^10.0.4:
|
||||
version "10.0.4"
|
||||
resolved "https://registry.yarnpkg.com/cacache/-/cacache-10.0.4.tgz#6452367999eff9d4188aefd9a14e9d7c6a263460"
|
||||
dependencies:
|
||||
|
@ -2171,16 +2171,6 @@ compressible@~2.0.13:
|
|||
dependencies:
|
||||
mime-db ">= 1.33.0 < 2"
|
||||
|
||||
compression-webpack-plugin@^1.1.8:
|
||||
version "1.1.11"
|
||||
resolved "https://registry.yarnpkg.com/compression-webpack-plugin/-/compression-webpack-plugin-1.1.11.tgz#8384c7a6ead1d2e2efb190bdfcdcf35878ed8266"
|
||||
dependencies:
|
||||
cacache "^10.0.1"
|
||||
find-cache-dir "^1.0.0"
|
||||
neo-async "^2.5.0"
|
||||
serialize-javascript "^1.4.0"
|
||||
webpack-sources "^1.0.1"
|
||||
|
||||
compression@^1.5.2:
|
||||
version "1.7.2"
|
||||
resolved "http://registry.npmjs.org/compression/-/compression-1.7.2.tgz#aaffbcd6aaf854b44ebb280353d5ad1651f59a69"
|
||||
|
@ -3542,15 +3532,6 @@ extglob@^2.0.4:
|
|||
snapdragon "^0.8.1"
|
||||
to-regex "^3.0.1"
|
||||
|
||||
extract-text-webpack-plugin@^3.0.2:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/extract-text-webpack-plugin/-/extract-text-webpack-plugin-3.0.2.tgz#5f043eaa02f9750a9258b78c0a6e0dc1408fb2f7"
|
||||
dependencies:
|
||||
async "^2.4.1"
|
||||
loader-utils "^1.1.0"
|
||||
schema-utils "^0.3.0"
|
||||
webpack-sources "^1.0.1"
|
||||
|
||||
extsprintf@1.3.0, extsprintf@^1.2.0:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05"
|
||||
|
@ -3629,7 +3610,7 @@ file-entry-cache@^2.0.0:
|
|||
flat-cache "^1.2.1"
|
||||
object-assign "^4.0.1"
|
||||
|
||||
file-loader@^1.1.7:
|
||||
file-loader@^1.1.11:
|
||||
version "1.1.11"
|
||||
resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-1.1.11.tgz#6fe886449b0f2a936e43cabaac0cdbfb369506f8"
|
||||
dependencies:
|
||||
|
@ -5620,6 +5601,13 @@ kind-of@^6.0.0, kind-of@^6.0.2:
|
|||
version "6.0.2"
|
||||
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051"
|
||||
|
||||
last-call-webpack-plugin@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/last-call-webpack-plugin/-/last-call-webpack-plugin-3.0.0.tgz#9742df0e10e3cf46e5c0381c2de90d3a7a2d7555"
|
||||
dependencies:
|
||||
lodash "^4.17.5"
|
||||
webpack-sources "^1.1.0"
|
||||
|
||||
lazy-cache@^1.0.3:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e"
|
||||
|
@ -6656,6 +6644,13 @@ optimist@^0.6.1:
|
|||
minimist "~0.0.1"
|
||||
wordwrap "~0.0.2"
|
||||
|
||||
optimize-css-assets-webpack-plugin@^4.0.2:
|
||||
version "4.0.2"
|
||||
resolved "https://registry.yarnpkg.com/optimize-css-assets-webpack-plugin/-/optimize-css-assets-webpack-plugin-4.0.2.tgz#813d511d20fe5d9a605458441ed97074d79c1122"
|
||||
dependencies:
|
||||
cssnano "^3.10.0"
|
||||
last-call-webpack-plugin "^3.0.0"
|
||||
|
||||
optionator@^0.8.1, optionator@^0.8.2:
|
||||
version "0.8.2"
|
||||
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64"
|
||||
|
@ -8314,12 +8309,6 @@ sax@^1.2.1, sax@^1.2.4, sax@~1.2.1:
|
|||
version "1.2.4"
|
||||
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
|
||||
|
||||
schema-utils@^0.3.0:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.3.0.tgz#f5877222ce3e931edae039f17eb3716e7137f8cf"
|
||||
dependencies:
|
||||
ajv "^5.0.0"
|
||||
|
||||
schema-utils@^0.4.0, schema-utils@^0.4.4, schema-utils@^0.4.5:
|
||||
version "0.4.5"
|
||||
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.4.5.tgz#21836f0608aac17b78f9e3e24daff14a5ca13a3e"
|
||||
|
@ -9268,7 +9257,7 @@ uglify-to-browserify@~1.0.0:
|
|||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7"
|
||||
|
||||
uglifyjs-webpack-plugin@^1.2.2, uglifyjs-webpack-plugin@^1.2.4:
|
||||
uglifyjs-webpack-plugin@^1.2.4, uglifyjs-webpack-plugin@^1.2.5:
|
||||
version "1.2.5"
|
||||
resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.2.5.tgz#2ef8387c8f1a903ec5e44fa36f9f3cbdcea67641"
|
||||
dependencies:
|
||||
|
|
Loading…
Reference in New Issue