try another PWA plugin,

debug .env on TEST/STAGING
improve /notify API
This commit is contained in:
Dobromir Popov
2024-05-06 15:59:42 +03:00
parent 9056ca4f4a
commit db31066724
11 changed files with 816 additions and 247 deletions

View File

@ -1,14 +1,15 @@
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const { InjectManifest } = require('workbox-webpack-plugin');
const withPWA = require('next-pwa')({
dest: 'public',
register: true, // ?
publicExcludes: ["!_error*.js"], //?
//disable: process.env.NODE_ENV === 'development',
disable: process.env.NODE_ENV === 'development',
})
module.exports = withPWA({
module.exports = {
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
@ -22,23 +23,41 @@ module.exports = withPWA({
env: process.env.NODE_ENV,
server: process.env.NEXT_PUBLIC_PUBLIC_URL
},
webpack(config, { isServer }) {
plugins: [
// Other plugins...
new InjectManifest({
// These are some common options, and not all are required.
// Consult the docs for more info.
//exclude: [/.../, '...'],
maximumFileSizeToCacheInBytes: 1 * 1024 * 1024,
swSrc: './worker/index.js',
}),
],
webpack: (config, { isServer, buildId, dev }) => {
// Configure optimization and source maps
config.optimization.minimize = !dev;
//config.productionBrowserSourceMaps = true;
// Enable source maps based on non-production environments
if (!dev) {
config.devtool = 'source-map';
}
// Add custom fallbacks
config.resolve.fallback = { ...config.resolve.fallback, fs: false };
config.optimization.minimize = true,
productionBrowserSourceMaps = true,
// InjectManifest configuration
if (!isServer) {
config.plugins.push(new InjectManifest({
swSrc: './worker/index.js', // Path to source service worker file
swDest: '/worker/index.js', // Destination filename in the build output
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024, // Adjust as needed
exclude: [/\.map$/, /_error.js$/, /favicon.ico$/] // Customize exclusion patterns
})
);
}
config.resolve.fallback = {
// if you miss it, all the other options in fallback, specified
// by next.js will be dropped.
...config.resolve.fallback,
fs: false, // the solution
};
// Only run the bundle analyzer for production builds and when the ANALYZE environment variable is set
// Bundle Analyzer Configuration
if (process.env.ANALYZE && !isServer) {
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'static',
@ -58,4 +77,4 @@ module.exports = withPWA({
defaultLocale: 'bg',
localeDetection: false,
},
})
}