Skip to content

Commit 9377891

Browse files
committed
Add sw-precache Service Worker caching
1 parent 41be99f commit 9377891

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

template/build/webpack.prod.conf.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var CopyWebpackPlugin = require('copy-webpack-plugin')
88
var HtmlWebpackPlugin = require('html-webpack-plugin')
99
var ExtractTextPlugin = require('extract-text-webpack-plugin')
1010
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
11+
var SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin')
1112

1213
var env = {{#if_or unit e2e}}process.env.NODE_ENV === 'testing'
1314
? require('../config/test.env')
@@ -94,7 +95,15 @@ var webpackConfig = merge(baseWebpackConfig, {
9495
to: config.build.assetsSubDirectory,
9596
ignore: ['.*']
9697
}
97-
])
98+
]),
99+
// service worker caching
100+
new SWPrecacheWebpackPlugin({
101+
cacheId: 'my-vue-app',
102+
filename: 'service-worker.js',
103+
staticFileGlobs: ['dist/**/*.{js,html,css}'],
104+
minify: true,
105+
stripPrefix: 'dist/'
106+
})
98107
]
99108
})
100109

template/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"devDependencies": {
2020
"autoprefixer": "^6.7.2",
2121
"babel-core": "^6.22.1",
22+
"sw-precache-webpack-plugin": "^0.9.1",
2223
{{#lint}}
2324
"babel-eslint": "^7.1.1",
2425
{{/lint}}

0 commit comments

Comments
 (0)