-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
85 lines (76 loc) · 2.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const path = require("path");
//const withCustomBabelConfigFile = require("next-plugin-custom-babel-config");
const withPWA = require("next-pwa")({ dest: "public", reloadOnOnline: false });
//const withPreact = require("next-plugin-preact");
const withTwin = require('./withTwin.js')
const {
PHASE_DEVELOPMENT_SERVER,
PHASE_PRODUCTION_BUILD,
PHASE_PRODUCTION_SERVER
} = require("next/constants");
let plugins = [
//withPreact,
withTwin,
//withPWA,
// withCustomBabelConfigFile({
// babelConfigFile: path.resolve("./babel.config.js")
// })
]
if (process.env.ANALYZE) {
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: true
});
plugins.unshift(withBundleAnalyzer)
}
const nextConfig = {
// async headers() {
// return [
// {
// // matching all API routes
// source: "/api/:path*",
// headers: [
// { key: "Access-Control-Allow-Credentials", value: "true" },
// { key: "Access-Control-Allow-Origin", value: process.env.NEXT_PUBLIC_URL },
// { key: "Access-Control-Allow-Origin", value: "https://beta.lebonforum.fr" },
// { key: "Access-Control-Allow-Methods", value: "GET,DELETE,PATCH,POST,PUT" },
// { key: "Access-Control-Allow-Headers", value: "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" },
// ]
// }
// ]
// },
eslint: {
ignoreDuringBuilds: true
},
i18n: {
locales: ["fr-FR"],
defaultLocale: "fr-FR"
},
swcMinify: false,
typescript: {
ignoreBuildErrors: true
},
// webpack(config, { dev, isServer }) {
// if (dev && !isServer) {
// const originalEntry = config.entry
// config.entry = async () => {
// const wdrPath = path.resolve(__dirname, './wdyr.ts')
// const entries = await originalEntry()
// if (entries['main.js'] && !entries['main.js'].includes(wdrPath)) {
// entries['main.js'].push(wdrPath)
// }
// return entries
// }
// }
// return config
// }
};
module.exports = (phase, defaultConfig) => {
if (phase === PHASE_PRODUCTION_SERVER || phase === PHASE_PRODUCTION_BUILD) {
plugins.unshift(withPWA)
}
const config = plugins.reduce((acc, plugin) => {
const update = plugin(acc);
return typeof update === "function" ? update(phase, defaultConfig) : update;
}, { ...nextConfig });
return config;
}