Skip to content

Commit 46dcc50

Browse files
update pwa config
1 parent ade6a2c commit 46dcc50

2 files changed

Lines changed: 17 additions & 23 deletions

File tree

editor/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ yarn-error.log*
3232

3333
# vercel
3434
.vercel
35+
36+
# pwa
37+
public/sw.js
38+
public/workbox*.js
39+
public/fallback*.js

editor/next.config.js

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const TerserPlugin = require("terser-webpack-plugin");
1+
const IS_DEV = process.env.NODE_ENV === "development";
2+
23
const withPlugins = require("next-compose-plugins");
3-
const withPWA = require("next-pwa");
44
const withTM = require("next-transpile-modules")([
55
// region @editor-app
66
"@editor-app/live-session",
@@ -60,6 +60,16 @@ const withTM = require("next-transpile-modules")([
6060
// -----------------------------
6161
]);
6262

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",
70+
},
71+
});
72+
6373
module.exports = withPlugins(
6474
[
6575
[withTM],
@@ -75,32 +85,11 @@ module.exports = withPlugins(
7585
],
7686
{
7787
webpack: (config) => {
78-
config.module.rules.push({
79-
type: "javascript/auto",
80-
test: /\.mjs$/,
81-
include: /node_modules/,
82-
});
83-
8488
config.resolve.fallback = {
8589
fs: false, // used by handlebars
8690
path: false, // used by handlebars
87-
crypto: false, // or crypto-browserify (used for totp auth)
88-
stream: false, // or stream-browserify (used for totp auth)
8991
};
9092

91-
// -----------------------------
92-
// for @flutter-builder classname issue
93-
config.optimization.minimizer.push(
94-
new TerserPlugin({
95-
parallel: true,
96-
terserOptions: {
97-
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
98-
keep_classnames: true,
99-
},
100-
})
101-
);
102-
// -----------------------------
103-
10493
return config;
10594
},
10695
async redirects() {

0 commit comments

Comments
 (0)