fix: fix runtime caching error and adjust rules (#3970)

* fix: fix runtime caching error and adjust rules

* fix: add cache config for ts and m3u8

* revert ts and m3u8 cache config to previous behaviour

* remove unused runtime caching config

* remove all runtime caching config

---------

Co-authored-by: Gabe Kangas <gabek@real-ity.com>
This commit is contained in:
heongle 2024-11-10 06:08:45 +08:00 committed by GitHub
parent 99acc19cee
commit 6399df7f9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,28 +3,10 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const { PHASE_DEVELOPMENT_SERVER } = require('next/constants');
const runtimeCaching = require('next-pwa/cache');
const withPWA = require('next-pwa')({
dest: 'public',
runtimeCaching: [
{
urlPattern: /\.(?:ts|m3u8)$/i,
handler: 'NetworkOnly',
},
{
urlPattern: (url) => { return url.pathname.startsWith("/admin/"); },
handler: 'NetworkOnly',
options: {
fetchOptions: { credentials: 'same-origin' }
}
},
{
urlPattern: (url) => { return url.pathname.startsWith("/api/"); },
handler: 'NetworkOnly',
},
...runtimeCaching,
],
runtimeCaching: [],
register: true,
skipWaiting: true,
disableDevLogs: true,
@ -77,7 +59,17 @@ module.exports = async phase => {
unoptimized: true,
},
swcMinify: true,
transpilePackages: [ "antd", "@ant-design", "rc-util", "rc-pagination", "rc-picker", "rc-notification", "rc-tooltip", "rc-tree", "rc-table" ],
transpilePackages: [
'antd',
'@ant-design',
'rc-util',
'rc-pagination',
'rc-picker',
'rc-notification',
'rc-tooltip',
'rc-tree',
'rc-table',
],
webpack(config) {
config.module.rules.push({
test: /\.svg$/i,