@@ -5,6 +5,7 @@ const pkg = require(path.resolve(process.cwd(), './package.json'))
55const notifier = require ( 'node-notifier' )
66const FriendlyErrorsWebpackPlugin = require ( 'friendly-errors-webpack-plugin' )
77const HtmlWebpackPlugin = require ( 'html-webpack-plugin' )
8+ const { GenerateSW } = require ( 'workbox-webpack-plugin' )
89const log = require ( '../log' )
910
1011const warnImage = path . resolve ( __dirname , '../assets/warn.png' )
@@ -34,8 +35,8 @@ module.exports = options => {
3435 filename : 'index.html' ,
3536 template : path . resolve ( __dirname , '../assets/template.ejs' ) ,
3637 inject : 'body' ,
37- chunks :[ 'index' ] ,
38- templateParameters :{
38+ chunks : [ 'index' ] ,
39+ templateParameters : {
3940 title : title ? title : `${ pkg . name } @${ pkg . version } ` ,
4041 development : true ,
4142 header,
@@ -46,8 +47,8 @@ module.exports = options => {
4647 filename : 'iframe.html' ,
4748 template : path . resolve ( __dirname , '../assets/template.ejs' ) ,
4849 inject : 'body' ,
49- chunks :[ 'iframe' ] ,
50- templateParameters :{
50+ chunks : [ 'iframe' ] ,
51+ templateParameters : {
5152 title : title ? title : `${ pkg . name } @${ pkg . version } ` ,
5253 development : true ,
5354 header,
@@ -64,7 +65,10 @@ module.exports = options => {
6465 require . resolve ( 'webpack/hot/dev-server' ) ,
6566 `${ require . resolve ( 'webpack-dev-server/client' ) } ?http://localhost:${ port } `
6667 )
67- config . plugins . push ( new webpack . HotModuleReplacementPlugin ( ) )
68+ config . plugins . push (
69+ new webpack . HotModuleReplacementPlugin ( ) ,
70+ new GenerateSW ( )
71+ )
6872
6973 return config
7074}
0 commit comments