-
Notifications
You must be signed in to change notification settings - Fork 3
/
next.config.mjs
65 lines (57 loc) · 1.68 KB
/
next.config.mjs
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
// import fs from 'fs';
import path, { dirname } from 'path';
import { fileURLToPath } from 'url';
import createNextIntlPlugin from 'next-intl/plugin';
const { NEXT_PUBLIC_BASE_PATH, LOCAL_IMAGES } = process.env;
const USE_LOCAL_IMAGES = LOCAL_IMAGES === 'true';
const __dirname = dirname(fileURLToPath(import.meta.url));
const withNextIntl = createNextIntlPlugin('./i18n.config.ts');
/** @type {import('next').NextConfig} */
const nextConfig = {
basePath: NEXT_PUBLIC_BASE_PATH,
output: 'export',
images: !USE_LOCAL_IMAGES
? {
loader: 'custom',
loaderFile: './src/lib/image-loader.ts'
}
: {
unoptimized: true
},
webpack: (config) => {
// for tokenization applet
config.resolve.alias = {
...config.resolve.alias,
sharp$: false,
'onnxruntime-node$': false
};
return config;
},
sassOptions: {
includePaths: [path.join(__dirname, 'src')],
prependData: (content, loaderContext) => {
const { resourcePath, rootContext } = loaderContext;
const relativePath = path.relative(rootContext, resourcePath);
let list = [`@use 'src/styles/resources'`];
if (relativePath.endsWith('.module.scss')) {
list = list.concat([
`@use 'src/styles/theme' as themes`,
`@use '@carbon/colors'`,
`@use '@carbon/layout'`,
`@use '@carbon/type'`
]);
}
const imports = [...list, ''].join(';\n');
return imports.trim() + content;
},
logger: {
warn: function (message) {
console.warn(message);
},
debug: function (message) {
console.log(message);
}
}
}
};
export default withNextIntl(nextConfig);