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

1092
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,7 +38,17 @@ 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: {
loaders: [
@ -51,12 +63,12 @@ module.exports = {
test: /\.css$/,
loaders: ['style-loader', 'css-loader']
}, {
test: /\.(png|jpg|svg|woff|woff2)?(\?v=\d+.\d+.\d+)?$/,
test: /\.(png|jpg|svg|woff|woff2)?(\?v=\d+.\d+.\d+)?$/,
loader: 'url-loader?limit=8192'
}, {
test: /\.(eot|ttf)$/,
test: /\.(eot|ttf)$/,
loader: 'file-loader'
}
}
]
}
};