add sw-precache

This commit is contained in:
Antti Pilto 2017-04-30 01:51:25 +03:00
parent 6cbe26f917
commit b9ef320d18
3 changed files with 863 additions and 250 deletions

1082
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load diff

View file

@ -32,6 +32,7 @@
"precss": "^1.4.0",
"react-hot-loader": "^1.3.0",
"style-loader": "^0.14.1",
"sw-precache-webpack-plugin": "^0.10.1",
"url-loader": "^0.5.7",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.4.2"

View file

@ -4,8 +4,10 @@ const path = require('path');
const autoprefixer = require('autoprefixer');
const precss = require('precss');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
module.exports = {
context: __dirname,
devtool: 'cheap-module-source-map',
entry: [
'./src/index'
@ -36,6 +38,16 @@ module.exports = {
return [autoprefixer, precss];
}
}
}),
new SWPrecacheWebpackPlugin( {
cacheId: 'kana-quiz',
filename: 'sw.js',
maximumFileSizeToCacheInBytes: 4194304,
minify: true,
runtimeCaching: [{
handler: 'cacheFirst',
urlPattern: /\.(woff2|svg|ttf|eot|woff|html)$/,
}],
})
],
module: {