-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathnext.config.ts
More file actions
63 lines (56 loc) · 1.87 KB
/
next.config.ts
File metadata and controls
63 lines (56 loc) · 1.87 KB
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
import type { NextConfig } from 'next';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || '';
const nextConfig: NextConfig = {
output: 'export',
basePath,
trailingSlash: true,
images: { unoptimized: true },
sassOptions: {
includePaths: [
path.resolve(__dirname, 'node_modules'),
path.resolve(__dirname, '../../node_modules'),
path.resolve(__dirname, '../../packages/react/src'),
],
},
webpack(config) {
// Source alias: resolve to package source (same pattern as docs app)
config.resolve.alias['@tiny-design/react'] = path.resolve(
__dirname,
'../../packages/react/src'
);
config.resolve.alias['@tiny-design/icons'] = path.resolve(
__dirname,
'../../packages/icons/src'
);
// ?raw imports: embed original file contents as strings at build time.
// We must exclude ?raw from existing oneOf rules so Next.js/SWC doesn't
// compile the TSX before we read it as plain text.
const rawQuery = /raw/;
for (const rule of config.module.rules) {
if (rule && typeof rule === 'object' && rule.oneOf) {
for (const oneOfRule of rule.oneOf) {
if (oneOfRule && typeof oneOfRule === 'object') {
// Add resourceQuery exclusion to each sub-rule
if (!oneOfRule.resourceQuery) {
oneOfRule.resourceQuery = { not: [rawQuery] };
} else if (oneOfRule.resourceQuery instanceof RegExp) {
oneOfRule.resourceQuery = {
and: [oneOfRule.resourceQuery],
not: [rawQuery],
};
}
}
}
}
}
config.module.rules.push({
resourceQuery: rawQuery,
type: 'asset/source',
});
return config;
},
};
export default nextConfig;