perf: use terser for service worker too (#816)
This commit is contained in:
parent
260f6acf0e
commit
3a335a9f4a
|
@ -2,8 +2,7 @@ const webpack = require('webpack')
|
|||
const config = require('sapper/config/webpack.js')
|
||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
||||
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
|
||||
const TerserWebpackPlugin = require('terser-webpack-plugin')
|
||||
|
||||
const terser = require('./terser.config')
|
||||
const isDev = process.env.NODE_ENV === 'development'
|
||||
|
||||
module.exports = {
|
||||
|
@ -35,22 +34,7 @@ module.exports = {
|
|||
},
|
||||
optimization: isDev ? {} : {
|
||||
minimizer: [
|
||||
new TerserWebpackPlugin({
|
||||
cache: true,
|
||||
parallel: true,
|
||||
sourceMap: true,
|
||||
terserOptions: {
|
||||
ecma: 6,
|
||||
mangle: true,
|
||||
compress: {
|
||||
pure_funcs: ['console.log']
|
||||
},
|
||||
output: {
|
||||
comments: false
|
||||
},
|
||||
safari10: true
|
||||
}
|
||||
})
|
||||
terser()
|
||||
],
|
||||
splitChunks: {
|
||||
chunks: 'async',
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const config = require('sapper/config/webpack.js')
|
||||
const terser = require('./terser.config')
|
||||
const webpack = require('webpack')
|
||||
|
||||
const isDev = config.dev
|
||||
|
@ -10,7 +11,10 @@ module.exports = {
|
|||
devtool: isDev ? 'inline-source-map' : 'source-map',
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.browser': true,
|
||||
'process.env.NODE_ENV': '"production"',
|
||||
'process.env.SAPPER_TIMESTAMP': process.env.SAPPER_TIMESTAMP || Date.now()
|
||||
})
|
||||
}),
|
||||
terser()
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
const TerserWebpackPlugin = require('terser-webpack-plugin')
|
||||
|
||||
module.exports = () => new TerserWebpackPlugin({
|
||||
cache: true,
|
||||
parallel: true,
|
||||
sourceMap: true,
|
||||
terserOptions: {
|
||||
ecma: 6,
|
||||
mangle: true,
|
||||
compress: {
|
||||
pure_funcs: ['console.log']
|
||||
},
|
||||
output: {
|
||||
comments: false
|
||||
},
|
||||
safari10: true
|
||||
}
|
||||
})
|
Loading…
Reference in New Issue