-
Notifications
You must be signed in to change notification settings - Fork 207
/
Copy pathpackemon.config.ts
35 lines (33 loc) · 1.02 KB
/
packemon.config.ts
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
const config = {
babelInput(config) {
config.plugins?.push([
require.resolve('babel-plugin-module-resolver'),
{
root: ['./src'],
alias: {
'@/core': './src/core',
'@/core-react': './src/core-react',
'@/ui-react': './src/ui/react',
'@': './src',
},
},
]);
},
// Adding support for React 18's "use client" directive
// Mostly used with Next.js apps
rollupOutput(config) {
config.plugins.push({
name: 'fix-use-client',
renderChunk(code) {
if (code.includes("'use client'")) {
// Remove the original directive and split into lines
const lines = code.replace("'use client';", '').split('\n');
// Filter out any empty lines and reconstruct
return `'use client';\n${lines.filter((line) => line.trim()).join('\n')}`;
}
return null; // Return null to keep the original code (https://rollupjs.org/plugin-development/#renderchunk)
},
});
},
};
export default config;