feat: precache web assets. Closes #3030 (#3032)

This commit is contained in:
Gabe Kangas
2023-05-19 13:56:45 -07:00
committed by GitHub
parent def4c48fd8
commit ddef3f421c
3 changed files with 1092 additions and 318 deletions

View File

@ -2,53 +2,63 @@ const withLess = require('next-with-less');
const withBundleAnalyzer = require('@next/bundle-analyzer')({ const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true', enabled: process.env.ANALYZE === 'true',
}); });
const withPWA = require('next-pwa')({
dest: 'public',
register: true,
skipWaiting: true,
publicExcludes: ['!img/platformlogos/**/*', '!styles/admin/**/*'],
buildExcludes: [/chunks\/pages\/admin.*/, '!**/admin/**/*'],
sourcemap: process.env.NODE_ENV === 'development',
});
module.exports = withBundleAnalyzer( module.exports = withPWA(
withLess({ withBundleAnalyzer(
productionBrowserSourceMaps: process.env.SOURCE_MAPS === 'true', withLess({
trailingSlash: true, productionBrowserSourceMaps: process.env.SOURCE_MAPS === 'true',
reactStrictMode: true, trailingSlash: true,
images: { reactStrictMode: true,
unoptimized: true, images: {
}, unoptimized: true,
swcMinify: true, },
webpack(config) { swcMinify: true,
config.module.rules.push({ webpack(config) {
test: /\.svg$/i, config.module.rules.push({
issuer: /\.[jt]sx?$/, test: /\.svg$/i,
use: ['@svgr/webpack'], issuer: /\.[jt]sx?$/,
}); use: ['@svgr/webpack'],
});
return config; return config;
}, },
async rewrites() { async rewrites() {
return [ return [
{ {
source: '/api/:path*', source: '/api/:path*',
destination: 'http://localhost:8080/api/:path*', // Proxy to Backend to work around CORS. destination: 'http://localhost:8080/api/:path*', // Proxy to Backend to work around CORS.
}, },
{ {
source: '/hls/:path*', source: '/hls/:path*',
destination: 'http://localhost:8080/hls/:path*', // Proxy to Backend to work around CORS. destination: 'http://localhost:8080/hls/:path*', // Proxy to Backend to work around CORS.
}, },
{ {
source: '/img/:path*', source: '/img/:path*',
destination: 'http://localhost:8080/img/:path*', // Proxy to Backend to work around CORS. destination: 'http://localhost:8080/img/:path*', // Proxy to Backend to work around CORS.
}, },
{ {
source: '/logo', source: '/logo',
destination: 'http://localhost:8080/logo', // Proxy to Backend to work around CORS. destination: 'http://localhost:8080/logo', // Proxy to Backend to work around CORS.
}, },
{ {
source: '/thumbnail.jpg', source: '/thumbnail.jpg',
destination: 'http://localhost:8080/thumbnail.jpg', // Proxy to Backend to work around CORS. destination: 'http://localhost:8080/thumbnail.jpg', // Proxy to Backend to work around CORS.
}, },
{ {
source: '/customjavascript', source: '/customjavascript',
destination: 'http://localhost:8080/customjavascript', // Proxy to Backend to work around CORS. destination: 'http://localhost:8080/customjavascript', // Proxy to Backend to work around CORS.
}, },
]; ];
}, },
pageExtensions: ['tsx'], pageExtensions: ['tsx'],
}), }),
),
); );

1302
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,9 @@
"linkifyjs": "^4.1.0", "linkifyjs": "^4.1.0",
"lodash": "4.17.21", "lodash": "4.17.21",
"next": "13.3.0", "next": "13.3.0",
"next-pwa": "^5.6.0",
"next-with-less": "2.0.5", "next-with-less": "2.0.5",
"next-with-workbox": "^3.0.5",
"picmo": "5.8.4", "picmo": "5.8.4",
"postcss-flexbugs-fixes": "5.0.2", "postcss-flexbugs-fixes": "5.0.2",
"prop-types": "15.8.1", "prop-types": "15.8.1",
@ -56,6 +58,8 @@
"slate-react": "0.94.2", "slate-react": "0.94.2",
"ua-parser-js": "1.0.35", "ua-parser-js": "1.0.35",
"video.js": "^8.3.0", "video.js": "^8.3.0",
"workbox-precaching": "^6.5.4",
"workbox-window": "^6.5.4",
"xstate": "4.37.2", "xstate": "4.37.2",
"yaml": "2.2.2" "yaml": "2.2.2"
}, },