@@ -4,7 +4,7 @@ const path = require('path'),
44 CopyWebpackPlugin = require ( 'copy-webpack-plugin' ) ,
55 MiniCssExtractPlugin = require ( "mini-css-extract-plugin" ) ,
66 ManifestPlugin = require ( 'webpack-manifest-plugin' ) ,
7- SWPrecacheWebpackPlugin = require ( 'sw-precache -webpack-plugin' ) ;
7+ { GenerateSW } = require ( 'workbox -webpack-plugin' ) ;
88
99const _PROD_ = process . env . NODE_ENV === 'production' ;
1010
@@ -155,7 +155,7 @@ module.exports = {
155155 maxAsyncRequests : 5 ,
156156 maxInitialRequests : 3 ,
157157 automaticNameDelimiter : '~' ,
158- name : true ,
158+ // name: true,
159159 cacheGroups : {
160160 react : {
161161 name : 'vendor' ,
@@ -187,36 +187,39 @@ module.exports = {
187187 // },
188188 // _DEV_: JSON.stringify(_DEV_),
189189 // }),
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+ // }),
210211 new MiniCssExtractPlugin ( {
211212 filename : "static/css/[name].[contenthash].css" ,
212213 } ) ,
213214 new webpack . ProvidePlugin ( {
214215 $http : [ resolve ( 'src/utils/http.ts' ) , 'default' ] ,
215216 $msg : [ resolve ( 'node_modules/antd/es/message/index.js' ) , 'default' ]
216217 } ) ,
217- new CopyWebpackPlugin ( [ {
218- from : resolve ( 'statics' ) ,
219- ignore : [ '.*' ]
220- } ] )
218+ new CopyWebpackPlugin ( {
219+ patterns : [ {
220+ from : resolve ( 'statics' ) ,
221+ // ignore: ['.*']
222+ } ]
223+ } )
221224 ]
222225}
0 commit comments