feat: pwa support

This commit is contained in:
Sonny
2023-11-30 14:02:59 +01:00
parent db5fef08fc
commit d7fe801aa2
9 changed files with 1624 additions and 111 deletions

View File

@@ -1,7 +1,11 @@
const { i18n } = require('./next-i18next.config');
const {
PHASE_DEVELOPMENT_SERVER,
PHASE_PRODUCTION_BUILD,
} = require('next/constants');
/** @type {import("next").NextConfig} */
const config = {
const nextConfig = {
i18n,
webpack(config) {
config.module.rules.push({
@@ -24,4 +28,12 @@ const config = {
output: 'standalone',
};
module.exports = config;
module.exports = (phase) => {
if (phase === PHASE_DEVELOPMENT_SERVER || phase === PHASE_PRODUCTION_BUILD) {
const withPWA = require('@ducanh2912/next-pwa').default({
dest: 'public',
});
return withPWA(nextConfig);
}
return nextConfig;
};