perf: use terser for service worker too (#816)
This commit is contained in:
		
							parent
							
								
									260f6acf0e
								
							
						
					
					
						commit
						3a335a9f4a
					
				
					 3 changed files with 25 additions and 19 deletions
				
			
		|  | @ -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() | ||||
|   ] | ||||
| } | ||||
|  |  | |||
							
								
								
									
										18
									
								
								webpack/terser.config.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								webpack/terser.config.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -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…
	
	Add table
		
		Reference in a new issue