File tree Expand file tree Collapse file tree 4 files changed +43
-0
lines changed
Expand file tree Collapse file tree 4 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const exec = require('child_process').execSync
55const webpack = require ( 'webpack' )
66const ExtractTextPlugin = require ( 'extract-text-webpack-plugin' )
77const ProgressPlugin = require ( 'webpack/lib/ProgressPlugin' )
8+ const OfflinePlugin = require ( 'offline-plugin' )
89const base = require ( './webpack.base' )
910const pkg = require ( '../package' )
1011const _ = require ( './utils' )
@@ -44,6 +45,15 @@ base.plugins.push(
4445 new webpack . optimize . CommonsChunkPlugin ( {
4546 name : 'vendor' ,
4647 filename : 'vendor.[chunkhash:8].js'
48+ } ) ,
49+ // progressive web app
50+ // it uses the publicPath in webpack config
51+ new OfflinePlugin ( {
52+ relativePaths : false ,
53+ AppCache : false ,
54+ ServiceWorker : {
55+ events : true
56+ }
4757 } )
4858)
4959
@@ -64,4 +74,16 @@ _.cssProcessors.forEach(processor => {
6474 } )
6575} )
6676
77+ // minimize webpack output
78+ base . stats = {
79+ // Add children information
80+ children : false ,
81+ // Add chunk information (setting this to `false` allows for a less verbose output)
82+ chunks : false ,
83+ // Add built modules information to chunk information
84+ chunkModules : false ,
85+ chunkOrigins : false ,
86+ modules : false
87+ }
88+
6789module . exports = base
Original file line number Diff line number Diff line change 11import './promise-polyfill'
22import { app } from './app'
33
4+ // enable progressive web app support (with offline-plugin)
5+ if ( process . env . NODE_ENV === 'production' ) {
6+ require ( './pwa' )
7+ }
8+
49app . $mount ( '#app' )
Original file line number Diff line number Diff line change 1+ import runtime from 'offline-plugin/runtime'
2+
3+ runtime . install ( {
4+ // When an update is ready, tell ServiceWorker to take control immediately:
5+ onUpdateReady ( ) {
6+ console . log ( 'update ready' )
7+ runtime . applyUpdate ( )
8+ } ,
9+
10+ // Reload to get the new version:
11+ onUpdated ( ) {
12+ console . log ( 'updated' )
13+ location . reload ( )
14+ }
15+ } )
Original file line number Diff line number Diff line change 4848 "friendly-errors-webpack-plugin" : " ^1.1.2" ,
4949 "html-webpack-plugin" : " ^2.22.0" ,
5050 "raw-loader" : " ^0.5.1" ,
51+ "offline-plugin" : " ^4.5.3" ,
5152 "postcss-loader" : " ^0.9.1" ,
5253 "postcss-nested" : " ^1.0.0" ,
5354 "style-loader" : " ^0.13.1" ,
You can’t perform that action at this time.
0 commit comments