'ss''
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
const { GenerateSW } = require("workbox-webpack-plugin");
|
||||
|
||||
const config = {
|
||||
projectName: "cityh5",
|
||||
|
||||
@@ -44,6 +46,42 @@ const config = {
|
||||
},
|
||||
h5: {
|
||||
webpackChain(chain) {
|
||||
if (
|
||||
process.env.NODE_ENV === "production" &&
|
||||
!chain.plugins.has("workbox")
|
||||
) {
|
||||
chain.plugin("workbox").use(GenerateSW, [
|
||||
{
|
||||
clientsClaim: true,
|
||||
skipWaiting: true,
|
||||
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024, // 10MB
|
||||
runtimeCaching: [
|
||||
{
|
||||
urlPattern: /.*\.(?:png|jpg|jpeg|svg|gif|ico)/,
|
||||
handler: "CacheFirst",
|
||||
options: {
|
||||
cacheName: "images-cache",
|
||||
expiration: {
|
||||
maxEntries: 50,
|
||||
maxAgeSeconds: 30 * 24 * 60 * 60,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
urlPattern: /.*\.(?:js|css)/,
|
||||
handler: "StaleWhileRevalidate",
|
||||
options: {
|
||||
cacheName: "static-resources",
|
||||
expiration: {
|
||||
maxEntries: 50,
|
||||
maxAgeSeconds: 7 * 24 * 60 * 60,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
}
|
||||
chain.module
|
||||
.rule("markdown")
|
||||
.test(/\.md$/)
|
||||
|
||||
Reference in New Issue
Block a user