-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
68 lines (57 loc) · 1.59 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
const merge = require('webpack-merge').default;
const { apiUrl } =
process.env.NODE_ENV == 'production' ? process.env : require('./config.json');
const { i18n } = require('./next-i18next.config');
/** @type {import('next').NextConfig} */
module.exports = {
reactStrictMode: true,
trailingSlash: true,
publicRuntimeConfig: {
apiUrl
},
i18n,
webpack: (config, { isServer }) => {
[
(
config.module.rules.find(
m => m.oneOf && m.oneOf.find(({ test: reg }) => reg.test('file.css'))
) || {}
).oneOf
]
.filter(Boolean)
.forEach(styleRules => {
[
styleRules.find(
({ test: reg, use }) =>
reg.test('file.module.css') && use.loader !== 'error-loader'
),
styleRules.find(
({ test: reg, use }) =>
reg.test('file.module.scss') && use.loader !== 'error-loader'
)
]
.filter(Boolean)
.forEach(cmr => {
// Find the item inside the 'use' list that defines css-loader
const cssLoaderConfig = cmr.use.find(({ loader }) =>
loader.includes('css-loader')
);
if (!(cssLoaderConfig && cssLoaderConfig.options)) return;
cssLoaderConfig.options.modules.exportLocalsConvention =
'camelCase';
});
});
if (!isServer) {
}
return merge(config, {
resolve: {
fallback: {
...(isServer ? {} : { fs: false })
},
alias: {
'@styles': '/src/shared/styles'
}
}
});
}
};