Skip to content

Commit 29a3813

Browse files
committed
Upgrade to Webpack 4 - first try
Signed-off-by: David Mehren <[email protected]>
1 parent 0017ddd commit 29a3813

File tree

7 files changed

+3035
-1422
lines changed

7 files changed

+3035
-1422
lines changed

.babelrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"presets": [
3-
"es2015"
3+
["env", {
4+
"targets": {
5+
"node": "6",
6+
"uglify": true
7+
}
8+
}]
49
],
510
"plugins": [
611
"transform-runtime"

package.json

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -154,35 +154,40 @@
154154
"url": "https://github.com/hackmdio/codimd.git"
155155
},
156156
"devDependencies": {
157-
"babel-cli": "^6.18.0",
158-
"babel-core": "^6.21.0",
159-
"babel-loader": "^6.2.10",
160-
"babel-plugin-transform-runtime": "^6.15.0",
161-
"babel-polyfill": "^6.22.0",
162-
"babel-preset-es2015": "^6.18.0",
163-
"babel-runtime": "^6.20.0",
164-
"copy-webpack-plugin": "^4.0.1",
165-
"css-loader": "^0.26.1",
157+
"babel-cli": "^6.26.0",
158+
"babel-core": "^6.26.3",
159+
"babel-loader": "^7.1.4",
160+
"babel-plugin-transform-runtime": "^6.23.0",
161+
"babel-polyfill": "^6.26.0",
162+
"babel-preset-env": "^1.7.0",
163+
"babel-preset-es2015": "^6.24.1",
164+
"babel-preset-stage-2": "^6.24.1",
165+
"babel-runtime": "^6.26.0",
166+
"copy-webpack-plugin": "^4.5.2",
167+
"css-loader": "^0.28.11",
166168
"doctoc": "^1.3.0",
167-
"ejs-loader": "^0.3.0",
168-
"exports-loader": "^0.6.3",
169-
"expose-loader": "^0.7.1",
170-
"extract-text-webpack-plugin": "^1.0.1",
171-
"file-loader": "^0.9.0",
172-
"html-webpack-plugin": "^2.25.0",
173-
"imports-loader": "^0.7.0",
174-
"json-loader": "^0.5.4",
169+
"ejs-loader": "^0.3.1",
170+
"exports-loader": "^0.7.0",
171+
"expose-loader": "^0.7.5",
172+
"extract-text-webpack-plugin": "^4.0.0-beta.0",
173+
"file-loader": "^1.1.11",
174+
"html-webpack-loader": "^0.0.5",
175+
"html-webpack-plugin": "^4.0.0-alpha",
176+
"imports-loader": "^0.8.0",
175177
"jsonlint": "^1.6.2",
176178
"less": "^2.7.1",
177-
"less-loader": "^2.2.3",
178-
"optimize-css-assets-webpack-plugin": "^1.3.0",
179-
"script-loader": "^0.7.0",
179+
"less-loader": "^4.1.0",
180+
"mini-css-extract-plugin": "^0.4.1",
181+
"optimize-css-assets-webpack-plugin": "^4.0.3",
182+
"script-loader": "^0.7.2",
180183
"standard": "^9.0.1",
181184
"string-loader": "^0.0.1",
182-
"style-loader": "^0.13.1",
183-
"url-loader": "^0.5.7",
184-
"webpack": "^1.14.0",
185-
"webpack-parallel-uglify-plugin": "^0.2.0"
185+
"style-loader": "^0.21.0",
186+
"uglifyjs-webpack-plugin": "^1.2.7",
187+
"url-loader": "^1.0.1",
188+
"webpack": "^4.14.0",
189+
"webpack-cli": "^3.0.8",
190+
"webpack-parallel-uglify-plugin": "^1.1.0"
186191
},
187192
"standard": {
188193
"globals": [

public/views/includes/header.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<% for (var css in htmlWebpackPlugin.files.css) { %>
2-
<link href="<%= webpackConfig.output.baseUrl %><%= htmlWebpackPlugin.files.css[css] %>" rel="stylesheet">
2+
<link href="<%= webpackConfig.output.baseUrl %><%= htmlWebpackPlugin.files.css[css].path %>" rel="stylesheet">
33
<% } %>

public/views/includes/scripts.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<script src="<%= webpackConfig.output.baseUrl %>/config"></script>
2-
<% for (var chunk in htmlWebpackPlugin.files.chunks) { %>
3-
<script src="<%= webpackConfig.output.baseUrl %><%= htmlWebpackPlugin.files.chunks[chunk].entry %>" defer></script>
2+
<% for (var js in htmlWebpackPlugin.files.js) { %>
3+
<script src="<%= webpackConfig.output.baseUrl %><%= htmlWebpackPlugin.files.js[js].path %>" defer></script>
44
<% } %>

webpack.production.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,42 @@ var webpack = require('webpack')
33
var path = require('path')
44
var ExtractTextPlugin = require('extract-text-webpack-plugin')
55
var OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')
6-
var ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin')
6+
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
7+
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
78

89
module.exports = [Object.assign({}, baseConfig, {
910
plugins: baseConfig.plugins.concat([
1011
new webpack.DefinePlugin({
1112
'process.env': {
1213
'NODE_ENV': JSON.stringify('production')
1314
}
14-
}),
15-
new ParallelUglifyPlugin({
16-
uglifyJS: {
17-
compress: {
18-
warnings: false
19-
},
20-
output: {
21-
max_line_len: 1000000
22-
},
23-
mangle: false,
24-
sourceMap: false
25-
}
26-
}),
27-
new ExtractTextPlugin('[name].[hash].css')
15+
})
2816
]),
2917

18+
optimization: {
19+
minimizer: [
20+
new UglifyJsPlugin({
21+
parallel: true,
22+
cache: true
23+
})
24+
],
25+
splitChunks: {
26+
chunks: 'async',
27+
minChunks: Infinity
28+
}
29+
},
30+
3031
output: {
3132
path: path.join(__dirname, 'public/build'),
3233
publicPath: '/build/',
33-
filename: '[id].[name].[hash].js',
34-
baseUrl: '<%- url %>'
34+
filename: '[id].[name].[hash].js'
35+
// baseUrl: '<%- url %>'
3536
}
3637
}), {
3738
entry: {
3839
htmlExport: path.join(__dirname, 'public/js/htmlExport.js')
3940
},
40-
module: {
41-
loaders: [{
42-
test: /\.css$/,
43-
loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
44-
}, {
45-
test: /\.scss$/,
46-
loader: ExtractTextPlugin.extract('style-loader', 'sass-loader')
47-
}, {
48-
test: /\.less$/,
49-
loader: ExtractTextPlugin.extract('style-loader', 'less-loader')
50-
}]
51-
},
41+
5242
output: {
5343
path: path.join(__dirname, 'public/build'),
5444
publicPath: '/build/',
@@ -61,6 +51,16 @@ module.exports = [Object.assign({}, baseConfig, {
6151
}
6252
}),
6353
new ExtractTextPlugin('html.min.css'),
64-
new OptimizeCssAssetsPlugin()
65-
]
54+
new OptimizeCssAssetsPlugin(),
55+
new MiniCssExtractPlugin()
56+
],
57+
module: {
58+
rules: [{
59+
test: /\.css$/,
60+
use: [
61+
MiniCssExtractPlugin.loader,
62+
'css-loader'
63+
]
64+
}]
65+
}
6666
}]

0 commit comments

Comments
 (0)