build: also uglify service worker
							parent
							
								
									2ca22656d6
								
							
						
					
					
						commit
						fe829aa850
					
				| 
						 | 
				
			
			@ -4,7 +4,7 @@
 | 
			
		|||
  // Check to make sure service workers are supported in the current browser,
 | 
			
		||||
  // and that the current page is accessed from a secure origin. Using a
 | 
			
		||||
  // service worker from an insecure origin will trigger JS console errors.
 | 
			
		||||
  const isLocalhost = Boolean(window.location.hostname === 'localhost' ||
 | 
			
		||||
  var isLocalhost = Boolean(window.location.hostname === 'localhost' ||
 | 
			
		||||
      // [::1] is the IPv6 localhost address.
 | 
			
		||||
      window.location.hostname === '[::1]' ||
 | 
			
		||||
      // 127.0.0.1/8 is considered localhost for IPv4.
 | 
			
		||||
| 
						 | 
				
			
			@ -26,7 +26,7 @@
 | 
			
		|||
            // i.e. whether there's an existing service worker.
 | 
			
		||||
            if (navigator.serviceWorker.controller) {
 | 
			
		||||
              // The updatefound event implies that registration.installing is set
 | 
			
		||||
              const installingWorker = registration.installing;
 | 
			
		||||
              var installingWorker = registration.installing;
 | 
			
		||||
 | 
			
		||||
              installingWorker.onstatechange = function() {
 | 
			
		||||
                switch (installingWorker.state) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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({
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue