-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.js
49 lines (45 loc) · 1.43 KB
/
next.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const path = require('path');
/* eslint-disable @typescript-eslint/no-var-requires */
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
compiler: {
reactRemoveProperties: process.env.NODE_ENV === 'production' && { properties: ['^data-testid$'] },
removeConsole: process.env.NODE_ENV === 'production' && { exclude: ["error", "warn"] },
styledComponents: {
ssr: true,
cssProp: process.env.NODE_ENV !== 'production',
displayName: process.env.NODE_ENV !== 'production',
}
},
webpack(config, { dev, isServer }) {
if (dev && !isServer) {
const originalEntry = config.entry
config.entry = async () => {
const wdrPath = path.resolve(__dirname, './scripts/wdyr.ts')
const entries = await originalEntry()
if (entries['main.js'] && !entries['main.js'].includes(wdrPath)) {
entries['main.js'].push(wdrPath)
}
return entries
}
}
return config
},
};
const withPlugins = require("next-compose-plugins");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
const withPwa = require("next-pwa")({
dest: "public",
disable: process.env.NODE_ENV === "development",
});
module.exports = async (phase) => {
const defaultConfig = {}
return withPlugins([
[withBundleAnalyzer],
[withPwa],
], nextConfig)(phase, { defaultConfig });
};