@@ -4,7 +4,7 @@ const path = require('path'),
4
4
CopyWebpackPlugin = require ( 'copy-webpack-plugin' ) ,
5
5
MiniCssExtractPlugin = require ( "mini-css-extract-plugin" ) ,
6
6
ManifestPlugin = require ( 'webpack-manifest-plugin' ) ,
7
- SWPrecacheWebpackPlugin = require ( 'sw-precache -webpack-plugin' ) ;
7
+ { GenerateSW } = require ( 'workbox -webpack-plugin' ) ;
8
8
9
9
const _PROD_ = process . env . NODE_ENV === 'production' ;
10
10
@@ -155,7 +155,7 @@ module.exports = {
155
155
maxAsyncRequests : 5 ,
156
156
maxInitialRequests : 3 ,
157
157
automaticNameDelimiter : '~' ,
158
- name : true ,
158
+ // name: true,
159
159
cacheGroups : {
160
160
react : {
161
161
name : 'vendor' ,
@@ -187,36 +187,39 @@ module.exports = {
187
187
// },
188
188
// _DEV_: JSON.stringify(_DEV_),
189
189
// }),
190
- new ManifestPlugin ( {
191
- fileName : 'asset-manifest.json'
192
- } ) ,
193
- new SWPrecacheWebpackPlugin ( {
194
- dontCacheBustUrlsMatching : / \. \w { 8 } \. / ,
195
- filename : 'serviceWorker.js' ,
196
- logger ( message ) {
197
- console . log ( message ) ;
198
- if ( message . indexOf ( 'Total precache size is' ) === 0 ) {
199
- return ;
200
- }
201
- if ( message . indexOf ( 'Skipping static resource' ) === 0 ) {
202
- return ;
203
- }
204
- } ,
205
- minify : true ,
206
- navigateFallback : '/index.html' ,
207
- navigateFallbackWhitelist : [ / ^ (? ! \/ _ _ ) .* / ] ,
208
- staticFileGlobsIgnorePatterns : [ / \. m a p $ / , / a s s e t - m a n i f e s t \. j s o n $ / ] ,
209
- } ) ,
190
+ new GenerateSW ( ) ,
191
+ // new ManifestPlugin({
192
+ // fileName: 'asset-manifest.json'
193
+ // }),
194
+ // new SWPrecacheWebpackPlugin({
195
+ // dontCacheBustUrlsMatching: /\.\w{8}\./,
196
+ // filename: 'serviceWorker.js',
197
+ // logger(message) {
198
+ // console.log(message);
199
+ // if (message.indexOf('Total precache size is') === 0) {
200
+ // return;
201
+ // }
202
+ // if (message.indexOf('Skipping static resource') === 0) {
203
+ // return;
204
+ // }
205
+ // },
206
+ // minify: true,
207
+ // navigateFallback: '/index.html',
208
+ // navigateFallbackWhitelist: [/^(?!\/__).*/],
209
+ // staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
210
+ // }),
210
211
new MiniCssExtractPlugin ( {
211
212
filename : "static/css/[name].[contenthash].css" ,
212
213
} ) ,
213
214
new webpack . ProvidePlugin ( {
214
215
$http : [ resolve ( 'src/utils/http.ts' ) , 'default' ] ,
215
216
$msg : [ resolve ( 'node_modules/antd/es/message/index.js' ) , 'default' ]
216
217
} ) ,
217
- new CopyWebpackPlugin ( [ {
218
- from : resolve ( 'statics' ) ,
219
- ignore : [ '.*' ]
220
- } ] )
218
+ new CopyWebpackPlugin ( {
219
+ patterns : [ {
220
+ from : resolve ( 'statics' ) ,
221
+ // ignore: ['.*']
222
+ } ]
223
+ } )
221
224
]
222
225
}
0 commit comments