Files
mwitnessing/next.config.js
Dobromir Popov db31066724 try another PWA plugin,
debug .env on TEST/STAGING
improve /notify API
2024-05-06 15:59:42 +03:00

80 lines
2.4 KiB
JavaScript

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',
})
module.exports = {
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
// !! WARN !!
ignoreBuildErrors: true,
},
compress: false,
pageExtensions: ['ts', 'tsx', 'md', 'mdx'], // Replace `jsx?` with `tsx?`
env: {
env: process.env.NODE_ENV,
server: process.env.NEXT_PUBLIC_PUBLIC_URL
},
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 };
// 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
})
);
}
// Bundle Analyzer Configuration
if (process.env.ANALYZE && !isServer) {
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: true,
generateStatsFile: true,
})
);
}
return config;
},
i18n: {
// next-intl
// https://next-intl-docs.vercel.app/docs/usage/messages
// using https://next-intl-docs.vercel.app/docs/getting-started/pages-router
locales: ['bg', 'en', 'ru'],
defaultLocale: 'bg',
localeDetection: false,
},
}