build: also uglify service worker

This commit is contained in:
Equim
2018-02-25 01:29:45 +08:00
parent 2ca22656d6
commit fe829aa850
2 changed files with 12 additions and 4 deletions

View File

@@ -84,8 +84,16 @@ var webpackConfig = merge(baseWebpackConfig, {
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency',
serviceWorkerLoader: `<script>${fs.readFileSync(path.join(__dirname,
'./service-worker-prod.js'), 'utf-8')}</script>`
serviceWorkerLoader: (() => {
let sw = fs.readFileSync(path.join(__dirname, './service-worker-prod.js'), 'utf-8')
let result = UglifyJS.minify(sw)
if (result.error == null) {
sw = result.code
}
return '<script>' + sw + '</script>'
})()
}),
// split vendor js into its own file
new webpack.optimize.CommonsChunkPlugin({