Upgrade to webpack 4 (#1337)

This commit is contained in:
ylemkimon
2018-05-28 12:20:33 +09:00
committed by Kevin Barabash
parent 5a9e4c1708
commit 25e07a7df6
3 changed files with 6051 additions and 1410 deletions

7392
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -18,7 +18,7 @@
"devDependencies": { "devDependencies": {
"babel-eslint": "^8.1.2", "babel-eslint": "^8.1.2",
"babel-jest": "^22.0.4", "babel-jest": "^22.0.4",
"babel-loader": "^7.1.2", "babel-loader": "^7.1.4",
"babel-plugin-transform-class-properties": "^6.23.0", "babel-plugin-transform-class-properties": "^6.23.0",
"babel-plugin-transform-runtime": "^6.15.0", "babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.18.0", "babel-preset-es2015": "^6.18.0",
@@ -26,11 +26,10 @@
"babel-register": "^6.26.0", "babel-register": "^6.26.0",
"benchmark": "^2.1.4", "benchmark": "^2.1.4",
"check-dependencies": "^1.1.0", "check-dependencies": "^1.1.0",
"css-loader": "^0.28.8", "css-loader": "^0.28.11",
"eslint": "^4.14.0", "eslint": "^4.14.0",
"eslint-plugin-flowtype": "^2.40.1", "eslint-plugin-flowtype": "^2.40.1",
"extract-text-webpack-plugin": "^3.0.2", "file-loader": "^1.1.11",
"file-loader": "^1.1.6",
"flow-bin": "^0.73.0", "flow-bin": "^0.73.0",
"jest": "^22.0.4", "jest": "^22.0.4",
"jest-serializer-html": "^4.0.1", "jest-serializer-html": "^4.0.1",
@@ -39,6 +38,7 @@
"jspngopt": "^0.2.0", "jspngopt": "^0.2.0",
"less": "^3.0.4", "less": "^3.0.4",
"less-loader": "^4.1.0", "less-loader": "^4.1.0",
"mini-css-extract-plugin": "^0.4.0",
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"pako": "1.0.4", "pako": "1.0.4",
"pre-commit": "^1.2.2", "pre-commit": "^1.2.2",
@@ -46,13 +46,14 @@
"rimraf": "^2.6.2", "rimraf": "^2.6.2",
"selenium-webdriver": "^2.48.2", "selenium-webdriver": "^2.48.2",
"sri-toolbox": "^0.2.0", "sri-toolbox": "^0.2.0",
"style-loader": "^0.19.1", "style-loader": "^0.21.0",
"stylelint": "^8.4.0", "stylelint": "^8.4.0",
"stylelint-config-standard": "^18.0.0", "stylelint-config-standard": "^18.0.0",
"uglifyjs-webpack-plugin": "^1.2.5", "uglifyjs-webpack-plugin": "^1.2.5",
"webpack": "^3.6.0", "webpack": "^4.8.3",
"webpack-bundle-analyzer": "^2.11.1", "webpack-bundle-analyzer": "^2.13.0",
"webpack-dev-server": "^2.7.1" "webpack-cli": "^2.1.3",
"webpack-dev-server": "^3.1.4"
}, },
"bin": "cli.js", "bin": "cli.js",
"scripts": { "scripts": {

View File

@@ -1,8 +1,7 @@
// @flow // @flow
const path = require('path'); const path = require('path');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const webpack = require('webpack');
/*:: /*::
type Target = {| type Target = {|
@@ -48,6 +47,7 @@ function createConfig(target /*: Target */, dev /*: boolean */,
}, },
}; };
return { return {
mode: dev ? 'development' : 'production',
context: __dirname, context: __dirname,
entry: { entry: {
[target.name]: target.entry, [target.name]: target.entry,
@@ -69,19 +69,18 @@ function createConfig(target /*: Target */, dev /*: boolean */,
}, },
{ {
test: /\.css$/, test: /\.css$/,
use: ExtractTextPlugin.extract({ use: [
fallback: 'style-loader', dev ? 'style-loader' : MiniCssExtractPlugin.loader,
use: [cssLoader], cssLoader,
}), ],
}, },
{ {
test: /\.less$/, test: /\.less$/,
use: ExtractTextPlugin.extract({ use: [
fallback: 'style-loader', dev ? 'style-loader' : MiniCssExtractPlugin.loader,
use: [cssLoader, { cssLoader,
loader: 'less-loader', 'less-loader',
}], ],
}),
}, },
{ {
test: /\.(ttf|woff|woff2)$/, test: /\.(ttf|woff|woff2)$/,
@@ -96,23 +95,26 @@ function createConfig(target /*: Target */, dev /*: boolean */,
}, },
externals: 'katex', externals: 'katex',
plugins: [ plugins: [
new webpack.EnvironmentPlugin({ !dev && new MiniCssExtractPlugin({
NODE_ENV: dev ? 'development' : 'production',
}),
dev && new webpack.NamedModulesPlugin(),
minimize && new UglifyJsPlugin({
uglifyOptions: {
output: {
ascii_only: true,
},
},
}),
new ExtractTextPlugin({
filename: minimize ? '[name].min.css' : '[name].css', filename: minimize ? '[name].min.css' : '[name].css',
disable: dev,
}), }),
].filter(Boolean), ].filter(Boolean),
devtool: dev && 'inline-source-map', devtool: dev && 'inline-source-map',
optimization: {
minimize,
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
output: {
ascii_only: true,
},
},
}),
],
},
performance: {
hints: false,
},
}; };
} }