-
-
Notifications
You must be signed in to change notification settings - Fork 329
/
webpack.config.js
104 lines (89 loc) · 2.36 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
const webpack = require('webpack');
const config = require('./config');
const CompressionPlugin = require("compression-webpack-plugin");
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const { VueLoaderPlugin } = require('vue-loader');
let plugins = [];
plugins.push(new VueLoaderPlugin());
if(config.build.sourceMap){
plugins.push(new webpack.SourceMapDevToolPlugin({
filename: '[name].map'
}))
}
plugins.push(new webpack.DefinePlugin({
'process.env': {
NODE_ENV: config.build.env
}
}));
if(config.build.gzip){
plugins.push(new CompressionPlugin({
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.(js)$/,
threshold: 10240,
minRatio: 0.8
}));
}
if(config.build.bundleAnalyzerReport){
plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerHost: '127.0.0.1',
analyzerPort: 8888,
reportFilename: 'report.html',
defaultSizes: 'parsed',
openAnalyzer: true,
generateStatsFile: false,
statsFilename: 'stats.json',
statsOptions: null,
logLevel: 'info'
}))
}
module.exports = {
resolve: {
alias: {
vue: 'vue/dist/vue.common.js'
}
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader', 'postcss-loader' ]
}
]
},
devServer: {
contentBase: [config.build.distPath, config.server.assetsPath],
historyApiFallback: true,
noInfo: true,
open: config.server.autoOpenBrowser,
port: config.server.port
},
entry: config.entry,
output: {
path: config.build.distPath,
library: 'VueDragResize',
filename: '[name].js',
libraryTarget: 'umd'
},
optimization: {
minimizer: [
new UglifyJsPlugin({
sourceMap: false
})
]
},
plugins: plugins
};