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';
|
2024-10-28 11:04:40 +08:00
|
|
|
const externals = ['playwright', 'langsmith'];
|
2024-07-23 16:25:11 +08:00
|
|
|
|
|
|
|
export default defineConfig({
|
2024-08-15 17:59:43 +08:00
|
|
|
buildConfig: [
|
|
|
|
{
|
|
|
|
asset: {
|
|
|
|
svgr: true,
|
|
|
|
},
|
2024-10-28 11:04:40 +08:00
|
|
|
alias: {
|
|
|
|
async_hooks: path.join(__dirname, './src/blank_polyfill.ts'),
|
|
|
|
},
|
2024-08-15 17:59:43 +08:00
|
|
|
format: 'umd',
|
|
|
|
dts: false,
|
2024-10-28 11:04:40 +08:00
|
|
|
input: {
|
|
|
|
report: 'src/index.tsx',
|
|
|
|
playground: 'src/playground.tsx',
|
|
|
|
},
|
|
|
|
umdModuleName: (path) => {
|
|
|
|
if (path.includes('playground')) {
|
|
|
|
return 'midscenePlayground';
|
|
|
|
}
|
|
|
|
return 'midsceneVisualizer';
|
|
|
|
},
|
|
|
|
autoExternal: false,
|
|
|
|
externals: [...externals],
|
2024-08-15 17:59:43 +08:00
|
|
|
platform: 'browser',
|
2024-10-28 11:04:40 +08:00
|
|
|
outDir: 'dist',
|
2024-08-15 17:59:43 +08:00
|
|
|
minify: {
|
2024-10-22 15:37:16 +08:00
|
|
|
compress: !!process.env.CI,
|
2024-08-15 17:59:43 +08:00
|
|
|
},
|
2024-10-21 16:30:07 +08:00
|
|
|
define: {
|
2024-10-28 11:04:40 +08:00
|
|
|
__VERSION__: JSON.stringify(version),
|
|
|
|
global: 'globalThis',
|
2024-10-21 16:30:07 +08:00
|
|
|
},
|
2024-10-28 11:04:40 +08:00
|
|
|
target: 'es6',
|
2024-07-28 17:24:09 +08:00
|
|
|
},
|
2024-08-15 17:59:43 +08:00
|
|
|
{
|
|
|
|
asset: {
|
|
|
|
svgr: true,
|
|
|
|
},
|
2024-10-28 11:04:40 +08:00
|
|
|
alias: {
|
|
|
|
async_hooks: path.join(__dirname, './src/blank_polyfill.ts'),
|
|
|
|
},
|
|
|
|
format: 'iife',
|
|
|
|
dts: false,
|
2024-08-15 17:59:43 +08:00
|
|
|
input: {
|
2024-10-28 11:04:40 +08:00
|
|
|
popup: 'src/extension/popup.ts',
|
|
|
|
worker: 'src/extension/worker.ts',
|
|
|
|
'playground-entry': 'src/extension/playground-entry.ts',
|
2024-07-23 16:25:11 +08:00
|
|
|
},
|
2024-08-15 17:59:43 +08:00
|
|
|
autoExternal: false,
|
2024-10-28 11:04:40 +08:00
|
|
|
externals: [...externals],
|
2024-08-15 17:59:43 +08:00
|
|
|
platform: 'browser',
|
2024-10-28 11:04:40 +08:00
|
|
|
outDir: 'unpacked-extension/lib',
|
|
|
|
target: 'es6',
|
2024-10-21 16:30:07 +08:00
|
|
|
define: {
|
|
|
|
__VERSION__: JSON.stringify(version),
|
2024-10-28 11:04:40 +08:00
|
|
|
global: 'globalThis',
|
|
|
|
},
|
|
|
|
minify: {
|
|
|
|
compress: !!process.env.CI,
|
2024-08-15 17:59:43 +08:00
|
|
|
},
|
|
|
|
},
|
2024-07-23 16:25:11 +08:00
|
|
|
],
|
2024-10-28 11:04:40 +08:00
|
|
|
plugins: [moduleTools(), modulePluginNodePolyfill()],
|
2024-07-23 16:25:11 +08:00
|
|
|
buildPreset: 'npm-component',
|
|
|
|
});
|