diff --git a/template/build/webpack.prod.conf.js b/template/build/webpack.prod.conf.js index 7ab7bfd..cce3cea 100644 --- a/template/build/webpack.prod.conf.js +++ b/template/build/webpack.prod.conf.js @@ -8,6 +8,7 @@ var ExtractTextPlugin = require('extract-text-webpack-plugin'), HtmlWebpackPlugin = require('html-webpack-plugin'), OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') + SWPrecachePlugin = require('sw-precache-webpack-plugin') module.exports = merge(baseWebpackConfig, { module: { @@ -70,6 +71,29 @@ module.exports = merge(baseWebpackConfig, { new webpack.optimize.CommonsChunkPlugin({ name: 'manifest', chunks: ['vendor'] + }), + // auto generate service-worker for caching static files + new SWPrecachePlugin({ + cacheId: 'quasar-app', + filename: 'service-worker-cache.js', + minify: true, + + staticFileGlobs: [ + 'js/**.js', + 'fonts/**.woff', + 'statics/*', + '/**.html', + '/**.css' + ], + + runtimeCaching: [{ + urlPattern: /\/.*/, + handler: 'cacheFirst' + }], + + dontCacheBustUrlsMatching: /./, + navigateFallback: '/' + }) ] }) diff --git a/template/package.json b/template/package.json index 54ae76c..7ebdcb8 100644 --- a/template/package.json +++ b/template/package.json @@ -16,6 +16,7 @@ "moment": "^2.15.0", "quasar-framework": "^0.13.4", "roboto-fontface": "^0.7.0", + "sw-precache-webpack-plugin": "^0.11.0", "vue": "^2.3.0", "vue-router": "^2.0.0" }, diff --git a/template/src/index.html b/template/src/index.html index d79d5dd..772df97 100644 --- a/template/src/index.html +++ b/template/src/index.html @@ -5,9 +5,15 @@ - + Quasar App +
diff --git a/template/src/statics/logo.png b/template/src/statics/logo.png new file mode 100644 index 0000000..0349c80 Binary files /dev/null and b/template/src/statics/logo.png differ diff --git a/template/src/statics/manifest.json b/template/src/statics/manifest.json new file mode 100644 index 0000000..070dcb1 --- /dev/null +++ b/template/src/statics/manifest.json @@ -0,0 +1,17 @@ +{ + "lang": "en", + "background_color": "#0273D4", + "theme_color": "#0273D4", + "name": "Your app name", + "short_name": "myApp", + "display": "standalone", + "start_url": "index.html", + "icons": [ + { + "src": "statics/logo.png", + "sizes": "144x144", + "type": "image/png" + } + ], + "orientation": "portrait" +}