-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
81 lines (74 loc) · 2.37 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
const path = require("path");
const log = console.log;
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
const withImages = require("next-images");
const nextConfig = () => {
return withBundleAnalyzer(
withImages({
// next-image's default list excluding svg
fileExtensions: [
"jpg",
"jpeg",
"png",
"gif",
"ico",
"webp",
"jp2",
"avif",
],
compress: false,
reactStrictMode: true,
basePath: "",
images: {
domains: ["s3.amazonaws.com"],
},
trailingSlash: true,
webpack: (config, { dev }) => {
if (!dev) {
config.devtool = "source-map";
for (const plugin of config.plugins) {
if (plugin.constructor.name === "UglifyJsPlugin") {
plugin.options.sourceMap = true;
break;
}
}
if (config.optimization && config.optimization.minimizer) {
for (const plugin of config.optimization.minimizer) {
if (plugin.constructor.name === "TerserPlugin") {
plugin.options.sourceMap = true;
break;
}
}
}
}
const oldAliases = config.resolve.alias;
const stylesPath = path.resolve(__dirname, "./styles/");
const dataPath = path.resolve(__dirname, "./data/");
const primitivesPath = path.resolve(__dirname, "./primitives/");
const contextPath = path.resolve(__dirname, "./context/");
const componentsPath = path.resolve(__dirname, "./components/");
const helpersPath = path.resolve(__dirname, "./helpers/");
const srcPath = path.resolve(__dirname, "./src/");
const imagesPath = path.resolve(__dirname, "./images/");
const utilsPath = path.resolve(__dirname, "./utils/");
const newResolveAlias = {
"@data": dataPath,
"@components": componentsPath,
"@context": contextPath,
"@primitives": primitivesPath,
"@helpers": helpersPath,
"@src": srcPath,
"@styles": stylesPath,
"@images": imagesPath,
"@utils": utilsPath,
...oldAliases,
};
config.resolve.alias = newResolveAlias;
return config;
},
})
);
};
module.exports = nextConfig;