|
1 | | -const TerserPlugin = require("terser-webpack-plugin"); |
| 1 | +const IS_DEV = process.env.NODE_ENV === "development"; |
| 2 | + |
| 3 | +const withPlugins = require("next-compose-plugins"); |
2 | 4 | const withTM = require("next-transpile-modules")([ |
3 | 5 | // region @editor-app |
4 | 6 | "@editor-app/live-session", |
@@ -58,49 +60,52 @@ const withTM = require("next-transpile-modules")([ |
58 | 60 | // ----------------------------- |
59 | 61 | ]); |
60 | 62 |
|
61 | | -module.exports = withTM({ |
62 | | - webpack: (config) => { |
63 | | - config.module.rules.push({ |
64 | | - type: "javascript/auto", |
65 | | - test: /\.mjs$/, |
66 | | - include: /node_modules/, |
67 | | - }); |
68 | | - |
69 | | - config.resolve.fallback = { |
70 | | - fs: false, // used by handlebars |
71 | | - path: false, // used by handlebars |
72 | | - crypto: false, // or crypto-browserify (used for totp auth) |
73 | | - stream: false, // or stream-browserify (used for totp auth) |
74 | | - }; |
75 | | - |
76 | | - // ----------------------------- |
77 | | - // for @flutter-builder classname issue |
78 | | - config.optimization.minimizer.push( |
79 | | - new TerserPlugin({ |
80 | | - parallel: true, |
81 | | - terserOptions: { |
82 | | - // https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions |
83 | | - keep_classnames: true, |
84 | | - }, |
85 | | - }) |
86 | | - ); |
87 | | - // ----------------------------- |
88 | | - |
89 | | - return config; |
| 63 | +const withPWA = require("next-pwa")({ |
| 64 | + register: true, |
| 65 | + dest: "public", |
| 66 | + disable: IS_DEV, |
| 67 | + fallbacks: { |
| 68 | + image: "/images/fallback.png", |
| 69 | + document: "/_offline", |
90 | 70 | }, |
91 | | - async redirects() { |
92 | | - return [ |
93 | | - { |
94 | | - // typo gaurd |
95 | | - source: "/preference", |
96 | | - destination: "/preferences", |
97 | | - permanent: true, |
98 | | - }, |
| 71 | +}); |
| 72 | + |
| 73 | +module.exports = withPlugins( |
| 74 | + [ |
| 75 | + [withTM], |
| 76 | + [ |
| 77 | + withPWA, |
99 | 78 | { |
100 | | - source: "/files/:key/:id", |
101 | | - destination: "/files/:key?node=:id", |
102 | | - permanent: false, |
| 79 | + pwa: { |
| 80 | + dest: "public", |
| 81 | + // swSrc: "sw.js", |
| 82 | + }, |
103 | 83 | }, |
104 | | - ]; |
105 | | - }, |
106 | | -}); |
| 84 | + ], |
| 85 | + ], |
| 86 | + { |
| 87 | + webpack: (config) => { |
| 88 | + config.resolve.fallback = { |
| 89 | + fs: false, // used by handlebars |
| 90 | + path: false, // used by handlebars |
| 91 | + }; |
| 92 | + |
| 93 | + return config; |
| 94 | + }, |
| 95 | + async redirects() { |
| 96 | + return [ |
| 97 | + { |
| 98 | + // typo gaurd |
| 99 | + source: "/preference", |
| 100 | + destination: "/preferences", |
| 101 | + permanent: true, |
| 102 | + }, |
| 103 | + { |
| 104 | + source: "/files/:key/:id", |
| 105 | + destination: "/files/:key?node=:id", |
| 106 | + permanent: false, |
| 107 | + }, |
| 108 | + ]; |
| 109 | + }, |
| 110 | + } |
| 111 | +); |
0 commit comments