forked from cybrespace/pinafore
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 config = require('sapper/config/webpack.js')
|
||||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
||||||
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
|
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
|
||||||
const TerserWebpackPlugin = require('terser-webpack-plugin')
|
const terser = require('./terser.config')
|
||||||
|
|
||||||
const isDev = process.env.NODE_ENV === 'development'
|
const isDev = process.env.NODE_ENV === 'development'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -35,22 +34,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
optimization: isDev ? {} : {
|
optimization: isDev ? {} : {
|
||||||
minimizer: [
|
minimizer: [
|
||||||
new TerserWebpackPlugin({
|
terser()
|
||||||
cache: true,
|
|
||||||
parallel: true,
|
|
||||||
sourceMap: true,
|
|
||||||
terserOptions: {
|
|
||||||
ecma: 6,
|
|
||||||
mangle: true,
|
|
||||||
compress: {
|
|
||||||
pure_funcs: ['console.log']
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
comments: false
|
|
||||||
},
|
|
||||||
safari10: true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
],
|
],
|
||||||
splitChunks: {
|
splitChunks: {
|
||||||
chunks: 'async',
|
chunks: 'async',
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const config = require('sapper/config/webpack.js')
|
const config = require('sapper/config/webpack.js')
|
||||||
|
const terser = require('./terser.config')
|
||||||
const webpack = require('webpack')
|
const webpack = require('webpack')
|
||||||
|
|
||||||
const isDev = config.dev
|
const isDev = config.dev
|
||||||
|
@ -10,7 +11,10 @@ module.exports = {
|
||||||
devtool: isDev ? 'inline-source-map' : 'source-map',
|
devtool: isDev ? 'inline-source-map' : 'source-map',
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
|
'process.browser': true,
|
||||||
|
'process.env.NODE_ENV': '"production"',
|
||||||
'process.env.SAPPER_TIMESTAMP': process.env.SAPPER_TIMESTAMP || Date.now()
|
'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