1
1
const webpack = require ( 'webpack' )
2
2
const CopyWebpackPlugin = require ( 'copy-webpack-plugin' )
3
3
const HtmlWebpackPlugin = require ( 'html-webpack-plugin' )
4
- const VueLoaderPlugin = require ( 'vue-loader/lib/plugin ' )
4
+ const { VueLoaderPlugin } = require ( 'vue-loader' )
5
5
const MiniCssExtractPlugin = require ( 'mini-css-extract-plugin' )
6
- const OptimizeCSSPlugin = require ( 'optimize- css-assets -webpack-plugin' )
6
+ const CssMinimizerPlugin = require ( " css-minimizer -webpack-plugin" ) ;
7
7
const TerserPlugin = require ( 'terser-webpack-plugin' )
8
8
const WorkboxPlugin = require ( 'workbox-webpack-plugin' )
9
9
const WebpackAnalyzerPlugin = require ( 'webpack-bundle-analyzer' ) . BundleAnalyzerPlugin
@@ -12,7 +12,7 @@ const CompressionPlugin = require('compression-webpack-plugin')
12
12
13
13
const path = require ( 'path' )
14
14
15
- function resolvePath ( dir ) {
15
+ function resolvePath ( dir ) {
16
16
return path . join ( __dirname , '..' , dir )
17
17
}
18
18
@@ -30,25 +30,32 @@ module.exports = {
30
30
] ,
31
31
output : {
32
32
path : resolvePath ( isCordova ? 'cordova/www' : 'www' ) ,
33
- filename : 'js/app.[hash ].js' ,
33
+ filename : 'js/app.[contenthash ].js' ,
34
34
publicPath : '/' ,
35
35
hotUpdateChunkFilename : 'hot/hot-update.js' ,
36
36
hotUpdateMainFilename : 'hot/hot-update.json'
37
37
} ,
38
38
resolve : {
39
+ fallback : {
40
+ "crypto" : require . resolve ( "crypto-browserify" ) ,
41
+ "stream" : require . resolve ( "stream-browserify" ) ,
42
+ "path" : require . resolve ( "path-browserify" ) ,
43
+ } ,
39
44
extensions : [ '.mjs' , '.js' , '.vue' , '.json' ] ,
40
45
alias : {
41
46
vue$ : 'vue/dist/vue.esm.js' ,
42
47
'@' : resolvePath ( 'src' )
43
48
}
44
49
} ,
45
- devtool : env === 'production' ? ( buildSourceMaps ) ? 'source-map' : 'none' : 'eval-source-map' ,
50
+ devtool : env === 'production' ? ( buildSourceMaps ) ? 'source-map' : false : 'eval-source-map' ,
46
51
devServer : {
47
52
hot : true ,
48
53
// open: true,
49
54
// compress: true,
50
- contentBase : '/www/' ,
51
- disableHostCheck : true ,
55
+ static : [
56
+ path . resolve ( __dirname , 'www' ) ,
57
+ ] ,
58
+ allowedHosts : "all" ,
52
59
historyApiFallback : true ,
53
60
// watchOptions: {
54
61
// poll: 1000,
@@ -63,9 +70,15 @@ module.exports = {
63
70
maxEntrypointSize : 2500000
64
71
} ,
65
72
optimization : {
66
- minimizer : [ new TerserPlugin ( {
67
- sourceMap : true
68
- } ) ]
73
+ moduleIds : env === 'production' ? undefined : 'named' ,
74
+ minimizer : [
75
+ new TerserPlugin ( {
76
+ terserOptions : {
77
+ sourceMap : true
78
+ }
79
+ } ) ,
80
+ new CssMinimizerPlugin ( ) ,
81
+ ]
69
82
} ,
70
83
module : {
71
84
rules : [
@@ -153,26 +166,23 @@ module.exports = {
153
166
} ,
154
167
{
155
168
test : / \. ( p n g | j p e ? g | g i f | s v g ) ( \? .* ) ? $ / ,
156
- loader : 'url-loader' ,
157
- options : {
158
- limit : 10000 ,
159
- name : 'images/[name].[ext]'
169
+ type : 'asset/resource' ,
170
+ generator : {
171
+ filename : 'images/[name].[ext]'
160
172
}
161
173
} ,
162
174
{
163
175
test : / \. ( m p 4 | w e b m | o g g | m p 3 | w a v | f l a c | a a c | m 4 a ) ( \? .* ) ? $ / ,
164
- loader : 'url-loader' ,
165
- options : {
166
- limit : 10000 ,
167
- name : 'media/[name].[ext]'
176
+ type : 'asset/resource' ,
177
+ generator : {
178
+ filename : 'media/[name].[ext]'
168
179
}
169
180
} ,
170
181
{
171
182
test : / \. ( w o f f 2 ? | e o t | t t f | o t f ) ( \? .* ) ? $ / ,
172
- loader : 'url-loader' ,
173
- options : {
174
- limit : 10000 ,
175
- name : 'fonts/[name].[ext]'
183
+ type : 'asset/resource' ,
184
+ generator : {
185
+ filename : 'fonts/[name].[ext]'
176
186
}
177
187
} ,
178
188
{
@@ -185,6 +195,9 @@ module.exports = {
185
195
]
186
196
} ,
187
197
plugins : [
198
+ new webpack . ProvidePlugin ( {
199
+ process : 'process/browser.js' ,
200
+ } ) ,
188
201
new webpack . DefinePlugin ( {
189
202
'process.env.NODE_ENV' : JSON . stringify ( env ) ,
190
203
'process.env.TARGET' : JSON . stringify ( target )
@@ -194,17 +207,10 @@ module.exports = {
194
207
new ESLintPlugin ( {
195
208
extensions : [ 'js' , 'vue' ]
196
209
} ) ,
197
- new OptimizeCSSPlugin ( {
198
- cssProcessorOptions : {
199
- safe : true ,
200
- map : { inline : false }
201
- }
202
- } ) ,
203
210
new webpack . optimize . ModuleConcatenationPlugin ( )
204
211
] : [
205
212
// Development only plugins
206
213
new webpack . HotModuleReplacementPlugin ( ) ,
207
- new webpack . NamedModulesPlugin ( )
208
214
] ) ,
209
215
new HtmlWebpackPlugin ( {
210
216
filename : './index.html' ,
@@ -220,7 +226,7 @@ module.exports = {
220
226
} : false
221
227
} ) ,
222
228
new MiniCssExtractPlugin ( {
223
- filename : 'css/app.[hash ].css'
229
+ filename : 'css/app.[contenthash ].css'
224
230
} ) ,
225
231
new CopyWebpackPlugin ( [
226
232
{
@@ -238,7 +244,8 @@ module.exports = {
238
244
] ) ,
239
245
...( ! isCordova ? [
240
246
new WorkboxPlugin . InjectManifest ( {
241
- swSrc : resolvePath ( 'src/service-worker.js' )
247
+ swSrc : resolvePath ( 'src/service-worker.js' ) ,
248
+ maximumFileSizeToCacheInBytes : 100000000 ,
242
249
} )
243
250
] : [ ] ) ,
244
251
...( env === 'production' ? [
0 commit comments