@@ -3,8 +3,7 @@ const path = require('path'),
3
3
styleRules = require ( './styleLoaderConf' ) ,
4
4
CopyWebpackPlugin = require ( 'copy-webpack-plugin' ) ,
5
5
MiniCssExtractPlugin = require ( "mini-css-extract-plugin" ) ,
6
- ManifestPlugin = require ( 'webpack-manifest-plugin' ) ,
7
- SWPrecacheWebpackPlugin = require ( 'sw-precache-webpack-plugin' ) ;
6
+ { GenerateSW} = require ( 'workbox-webpack-plugin' ) ;
8
7
9
8
const DonePlugin = require ( './donePlugin' )
10
9
const _PROD_ = process . env . NODE_ENV === 'production' ;
@@ -24,7 +23,7 @@ module.exports = {
24
23
publicPath : '/' , // root Dir
25
24
sourceMapFilename : '[name].map' ,
26
25
chunkFilename : 'static/js/[name].[chunkhash:8].js' ,
27
- filename : 'static/js/[name].[hash :8].js'
26
+ filename : 'static/js/[name].[contenthash :8].js'
28
27
} ,
29
28
30
29
resolveLoader : {
@@ -84,15 +83,15 @@ module.exports = {
84
83
test : / \. ( e o t | w o f f | w o f f 2 | t t f ) ( \? \S * ) ? $ / ,
85
84
loader : "url-loader" ,
86
85
options : {
87
- name : "assets/fonts/[name].[hash :8].[ext]" ,
86
+ name : "assets/fonts/[name].[contenthash :8].[ext]" ,
88
87
limit : 2048
89
88
}
90
89
} ,
91
90
{
92
91
test : / \. ( s v g | p n g | j p e ? g | g i f ) ( \? \S * ) ? $ / ,
93
92
loader : "url-loader" ,
94
93
options : {
95
- name : "assets/imgs/[name].[hash :8].[ext]" ,
94
+ name : "assets/imgs/[name].[contenthash :8].[ext]" ,
96
95
limit : 2048
97
96
}
98
97
}
@@ -156,7 +155,7 @@ module.exports = {
156
155
maxAsyncRequests : 5 ,
157
156
maxInitialRequests : 3 ,
158
157
automaticNameDelimiter : '~' ,
159
- name : true ,
158
+ // name: true,
160
159
cacheGroups : {
161
160
react : {
162
161
name : 'vendor' ,
@@ -190,36 +189,39 @@ module.exports = {
190
189
// },
191
190
// _DEV_: JSON.stringify(_DEV_),
192
191
// }),
193
- new ManifestPlugin ( {
194
- fileName : 'asset-manifest.json'
195
- } ) ,
196
- new SWPrecacheWebpackPlugin ( {
197
- dontCacheBustUrlsMatching : / \. \w { 8 } \. / ,
198
- filename : 'serviceWorker.js' ,
199
- logger ( message ) {
200
- console . log ( message ) ;
201
- if ( message . indexOf ( 'Total precache size is' ) === 0 ) {
202
- return ;
203
- }
204
- if ( message . indexOf ( 'Skipping static resource' ) === 0 ) {
205
- return ;
206
- }
207
- } ,
208
- minify : true ,
209
- navigateFallback : '/index.html' ,
210
- navigateFallbackWhitelist : [ / ^ (? ! \/ _ _ ) .* / ] ,
211
- staticFileGlobsIgnorePatterns : [ / \. m a p $ / , / a s s e t - m a n i f e s t \. j s o n $ / ] ,
212
- } ) ,
192
+ // new GenerateSW(),
193
+ // new ManifestPlugin({
194
+ // fileName: 'asset-manifest.json'
195
+ // }),
196
+ // new SWPrecacheWebpackPlugin({
197
+ // dontCacheBustUrlsMatching: /\.\w{8}\./,
198
+ // filename: 'serviceWorker.js',
199
+ // logger(message) {
200
+ // console.log(message);
201
+ // if (message.indexOf('Total precache size is') === 0) {
202
+ // return;
203
+ // }
204
+ // if (message.indexOf('Skipping static resource') === 0) {
205
+ // return;
206
+ // }
207
+ // },
208
+ // minify: true,
209
+ // navigateFallback: '/index.html',
210
+ // navigateFallbackWhitelist: [/^(?!\/__).*/],
211
+ // staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
212
+ // }),
213
213
new MiniCssExtractPlugin ( {
214
214
filename : "static/css/[name].[contenthash].css" ,
215
215
} ) ,
216
216
new webpack . ProvidePlugin ( {
217
217
$http : [ resolve ( 'src/utils/http.ts' ) , 'default' ] ,
218
218
$msg : [ resolve ( 'node_modules/antd/es/message/index.js' ) , 'default' ]
219
219
} ) ,
220
- new CopyWebpackPlugin ( [ {
221
- from : resolve ( 'statics' ) ,
222
- ignore : [ '.*' ]
223
- } ] )
220
+ new CopyWebpackPlugin ( {
221
+ patterns : [ {
222
+ from : resolve ( 'statics' ) ,
223
+ // ignore: ['.*']
224
+ } ]
225
+ } )
224
226
]
225
227
}
0 commit comments