Disable SW caching in dev build

This commit is contained in:
Pavel Djundik 2020-01-09 22:40:10 +02:00
parent 23ac0fef32
commit fbdd888c3d
2 changed files with 9 additions and 3 deletions

View file

@ -78,7 +78,10 @@ async function networkOrCache(event) {
}
if (response.ok) {
event.waitUntil(putInCache(event.request, response));
if (cacheName !== "dev") {
event.waitUntil(putInCache(event.request, response));
}
return response.clone();
}

View file

@ -7,8 +7,9 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const VueLoaderPlugin = require("vue-loader/lib/plugin");
const Helper = require("./src/helper.js");
const isProduction = process.env.NODE_ENV === "production";
const config = {
mode: process.env.NODE_ENV === "production" ? "production" : "development",
mode: isProduction ? "production" : "development",
entry: {
"js/bundle.js": [path.resolve(__dirname, "client/js/vue.js")],
},
@ -108,7 +109,9 @@ const config = {
from: "./client/service-worker.js",
to: "[name].[ext]",
transform(content) {
return content.toString().replace("__HASH__", Helper.getVersionCacheBust());
return content
.toString()
.replace("__HASH__", isProduction ? Helper.getVersionCacheBust() : "dev");
},
},
{