2024-10-28 11:04:40 +08:00
|
|
|
import path from 'node:path';
|
2024-08-04 08:28:19 +08:00
|
|
|
import { defineConfig, moduleTools } from '@modern-js/module-tools';
|
2024-10-28 11:04:40 +08:00
|
|
|
import { modulePluginNodePolyfill } from '@modern-js/plugin-module-node-polyfill';
|
2024-10-21 16:30:07 +08:00
|
|
|
import { version } from './package.json';
|
2025-04-02 19:12:52 +08:00
|
|
|
const externals = [
|
|
|
|
'playwright',
|
|
|
|
'bufferutil',
|
|
|
|
'utf-8-validate',
|
|
|
|
'antd',
|
|
|
|
'@ant-design/icons',
|
|
|
|
'react',
|
|
|
|
'react-dom',
|
|
|
|
];
|
2024-07-23 16:25:11 +08:00
|
|
|
|
2024-11-05 11:49:21 +08:00
|
|
|
const commonConfig = {
|
|
|
|
asset: {
|
|
|
|
svgr: true,
|
|
|
|
},
|
|
|
|
autoExternal: false,
|
|
|
|
externals: [...externals],
|
2025-03-07 17:20:18 +08:00
|
|
|
target: 'es2020',
|
2024-11-05 11:49:21 +08:00
|
|
|
minify: process.env.CI
|
|
|
|
? {
|
|
|
|
compress: true,
|
|
|
|
}
|
|
|
|
: undefined,
|
|
|
|
define: {
|
2025-01-07 11:10:28 +08:00
|
|
|
__VERSION__: version,
|
2024-11-05 11:49:21 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2024-07-23 16:25:11 +08:00
|
|
|
export default defineConfig({
|
2024-08-15 17:59:43 +08:00
|
|
|
buildConfig: [
|
2025-03-19 15:22:17 +08:00
|
|
|
{
|
|
|
|
...commonConfig,
|
|
|
|
alias: {
|
|
|
|
async_hooks: path.join(__dirname, './src/blank_polyfill.ts'),
|
|
|
|
},
|
|
|
|
dts: false,
|
|
|
|
input: {
|
2025-04-02 19:12:52 +08:00
|
|
|
index: 'src/index.tsx',
|
2025-03-19 15:22:17 +08:00
|
|
|
},
|
|
|
|
platform: 'browser',
|
|
|
|
outDir: 'dist',
|
|
|
|
target: 'es2020',
|
2025-04-02 19:12:52 +08:00
|
|
|
externals: [...externals],
|
2024-07-28 17:24:09 +08:00
|
|
|
},
|
2024-07-23 16:25:11 +08:00
|
|
|
],
|
2024-11-05 11:49:21 +08:00
|
|
|
plugins: [
|
|
|
|
moduleTools(),
|
|
|
|
modulePluginNodePolyfill({
|
|
|
|
excludes: ['console'],
|
|
|
|
}),
|
|
|
|
],
|
2024-07-23 16:25:11 +08:00
|
|
|
buildPreset: 'npm-component',
|
|
|
|
});
|