Repository navigation
Expand file tree
/
Copy pathcreateConfig.js
More file actions
150 lines (144 loc) · 3.97 KB
/
Copy pathcreateConfig.js
File metadata and controls
150 lines (144 loc) · 3.97 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
const path = require('path')
const webpack = require('webpack')
const merge = require('webpack-merge')
const { VueLoaderPlugin } = require('vue-loader')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
module.exports = (config, target = { chrome: 52, firefox: 48 }) => {
const bubleOptions = {
target,
objectAssign: 'Object.assign',
transforms: {
forOf: false,
modules: false
}
}
const baseConfig = {
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
resolve: {
alias: {
src: path.resolve(__dirname, '../src'),
views: path.resolve(__dirname, '../src/devtools/views'),
components: path.resolve(__dirname, '../src/devtools/components'),
filters: path.resolve(__dirname, '../src/devtools/filters')
}
},
module: {
rules: [
{
test: /\.js$/,
loader: 'buble-loader',
exclude: /node_modules|vue\/dist|vuex\/dist/,
options: bubleOptions
},
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
compilerOptions: {
preserveWhitespace: false
},
transpileOptions: bubleOptions
}
},
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader',
'postcss-loader'
]
},
{
test: /\.styl(us)?$/,
use: [
'vue-style-loader',
'css-loader',
'postcss-loader',
'stylus-loader',
{
loader: 'style-resources-loader',
options: {
patterns: [
path.resolve(__dirname, '../src/devtools/style/imports.styl')
]
}
}
]
},
{
test: /\.(png|woff2)$/,
loader: 'url-loader?limit=0'
}
]
},
performance: {
hints: false
},
plugins: [
new VueLoaderPlugin(),
...(process.env.VUE_DEVTOOL_TEST ? [] : [new FriendlyErrorsPlugin()]),
new webpack.DefinePlugin({
'process.env.RELEASE_CHANNEL': JSON.stringify(process.env.RELEASE_CHANNEL || 'stable')
})
],
devServer: {
port: process.env.PORT
},
stats: {
colors: true
}
}
if (process.env.NODE_ENV === 'production') {
const UglifyPlugin = require('uglifyjs-webpack-plugin')
baseConfig.plugins.push(
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
})
)
baseConfig.optimization = {
minimizer: [
new UglifyPlugin({
exclude: /backend/,
uglifyOptions: {
compress: {
// turn off flags with small gains to speed up minification
arrows: false,
collapse_vars: false, // 0.3kb
comparisons: false,
computed_props: false,
hoist_funs: false,
hoist_props: false,
hoist_vars: false,
inline: false,
loops: false,
negate_iife: false,
properties: false,
reduce_funcs: false,
reduce_vars: false,
switches: false,
toplevel: false,
typeofs: false,
// a few flags with noticable gains/speed ratio
// numbers based on out of the box vendor bundle
booleans: true, // 0.7kb
if_return: true, // 0.4kb
sequences: true, // 0.7kb
unused: true, // 2.3kb
// required features to drop conditional branches
conditionals: true,
dead_code: true,
evaluate: true
},
mangle: {
safari10: true
}
},
sourceMap: false,
cache: true,
parallel: true
})
]
}
}
return merge(baseConfig, config)
}