Skip to content

Commit 0283c88

Browse files
author
陈峰
committed
upgrade to webpack 4
1 parent 147e0dc commit 0283c88

File tree

4 files changed

+1129
-738
lines changed

4 files changed

+1129
-738
lines changed

build/webpack.config.js

+25-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
const path = require('path');
2-
const webpack = require('webpack')
2+
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
3+
const VueLoaderPlugin = require('vue-loader/lib/plugin');
34
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
45

56
module.exports = {
7+
mode: 'production',
68
entry: './lib/index.js',
9+
optimization: {
10+
minimizer: [
11+
new UglifyJsPlugin({
12+
cache: true,
13+
parallel: true,
14+
sourceMap: true,
15+
uglifyOptions: {
16+
compress: {
17+
warnings: false
18+
},
19+
comments: false
20+
}
21+
}),
22+
],
23+
},
724
output: {
825
path: path.join(__dirname, '../dist'),
926
filename: 'vue-json-viewer.js',
@@ -27,8 +44,8 @@ module.exports = {
2744
exclude: /node_modules/
2845
},
2946
{
30-
test: /\.css$/,
31-
use: ['vue-style-loader', 'css-loader', 'autoprefixer-loader']
47+
test: /\.s?css$/,
48+
use: ['vue-style-loader', 'css-loader', 'postcss-loader', 'sass-loader']
3249
},
3350
{
3451
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
@@ -55,15 +72,10 @@ module.exports = {
5572
]
5673
},
5774
plugins: [
58-
new webpack.optimize.UglifyJsPlugin({
59-
parallel: true,
60-
uglifyOptions: {
61-
compress: {
62-
warnings: false
63-
},
64-
comments: false
65-
}
66-
}),
67-
// new BundleAnalyzerPlugin()
75+
new VueLoaderPlugin()
6876
]
6977
}
78+
79+
if (process.argv.some(a => a === '--report')) {
80+
module.exports.plugins.push(new BundleAnalyzerPlugin());
81+
}

package.json

+10-8
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,10 @@
4343
],
4444
"dependencies": {
4545
"clipboard": "^1.7.1",
46-
"vue": "^2.5.2"
46+
"vue": "^2.6.9"
4747
},
4848
"devDependencies": {
4949
"autoprefixer": "^7.1.5",
50-
"autoprefixer-loader": "^3.2.0",
5150
"babel-core": "^6.26.0",
5251
"babel-eslint": "^8.0.1",
5352
"babel-loader": "^7.1.2",
@@ -61,17 +60,20 @@
6160
"eslint": "^5.6.0",
6261
"eslint-plugin-vue": "^5.0.0-beta.3",
6362
"file-loader": "^1.1.5",
64-
"html-webpack-plugin": "^2.30.1",
63+
"html-webpack-plugin": "^3.2.0",
6564
"node-sass": "^4.5.3",
65+
"postcss-loader": "^3.0.0",
6666
"sass-loader": "^6.0.6",
6767
"style-loader": "^0.19.0",
68+
"uglifyjs-webpack-plugin": "^2.1.2",
6869
"url-loader": "^0.6.2",
69-
"vue-loader": "^13.3.0",
70-
"vue-style-loader": "^3.0.3",
71-
"vue-template-compiler": "^2.5.2",
72-
"webpack": "^3.8.1",
70+
"vue-loader": "^15.7.0",
71+
"vue-style-loader": "^4.1.2",
72+
"vue-template-compiler": "^2.6.9",
73+
"webpack": "^4.29.6",
7374
"webpack-bundle-analyzer": "^3.0.2",
74-
"webpack-dev-server": "^2.9.2",
75+
"webpack-cli": "^3.3.0",
76+
"webpack-dev-server": "3.1.11",
7577
"webpack-merge": "^4.1.0"
7678
}
7779
}

postcss.config.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
sourceMap: false,
3+
plugins: [
4+
require('autoprefixer')({
5+
browsers: ['> 1%', 'android >=4', 'ios >=8']
6+
})
7+
]
8+
};

0 commit comments

Comments
 (0)