2025-02-07 14:55:52 +08:00
|
|
|
import fs from 'node:fs';
|
|
|
|
import path from 'node:path';
|
2024-08-04 08:28:19 +08:00
|
|
|
import { defineConfig, moduleTools } from '@modern-js/module-tools';
|
2025-01-07 11:10:28 +08:00
|
|
|
import { version } from './package.json';
|
2024-07-23 16:25:11 +08:00
|
|
|
|
2025-02-07 14:55:52 +08:00
|
|
|
// Create directories and copy files
|
|
|
|
// The file copying functionality in modern.js is not operating correctly.
|
|
|
|
const files = [
|
|
|
|
[
|
|
|
|
'node_modules/@midscene/shared/dist/script/htmlElement.js',
|
|
|
|
'iife-script/htmlElement.js',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'node_modules/@midscene/shared/dist/script/htmlElementDebug.js',
|
|
|
|
'iife-script/htmlElementDebug.js',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
files.forEach(([src, dest]) => {
|
|
|
|
// Create parent directory if it doesn't exist
|
|
|
|
const destDir = path.dirname(path.join(__dirname, dest));
|
|
|
|
fs.mkdirSync(destDir, { recursive: true });
|
|
|
|
// Copy file
|
|
|
|
fs.copyFileSync(path.join(__dirname, src), path.join(__dirname, dest));
|
|
|
|
});
|
|
|
|
|
2024-07-23 16:25:11 +08:00
|
|
|
export default defineConfig({
|
|
|
|
plugins: [moduleTools()],
|
|
|
|
buildPreset: 'npm-library',
|
|
|
|
buildConfig: {
|
2025-03-09 21:50:20 +08:00
|
|
|
target: 'es2020',
|
|
|
|
buildType: 'bundle',
|
|
|
|
input: {
|
|
|
|
index: 'src/index.ts',
|
|
|
|
'bridge-mode': 'src/bridge-mode/index.ts',
|
|
|
|
'bridge-mode-browser': 'src/bridge-mode/browser.ts',
|
|
|
|
utils: 'src/common/utils.ts',
|
|
|
|
'ui-utils': 'src/common/ui-utils.ts',
|
|
|
|
puppeteer: 'src/puppeteer/index.ts',
|
2025-04-17 10:50:16 +08:00
|
|
|
'puppeteer-agent-launcher': 'src/puppeteer/agent-launcher.ts',
|
2025-03-09 21:50:20 +08:00
|
|
|
playwright: 'src/playwright/index.ts',
|
|
|
|
playground: 'src/playground/index.ts',
|
|
|
|
'midscene-playground': 'src/playground/bin.ts',
|
2025-04-17 17:44:11 +08:00
|
|
|
'midscene-server': 'src/playground/server.ts',
|
2025-03-09 21:50:20 +08:00
|
|
|
'playwright-report': './src/playwright/reporter/index.ts',
|
|
|
|
'chrome-extension': 'src/chrome-extension/index.ts',
|
|
|
|
yaml: 'src/yaml/index.ts',
|
2025-04-03 10:28:40 +08:00
|
|
|
agent: 'src/common/agent.ts',
|
2025-03-09 21:50:20 +08:00
|
|
|
},
|
|
|
|
externals: [
|
|
|
|
'@midscene/core',
|
|
|
|
'@midscene/shared',
|
|
|
|
'puppeteer',
|
|
|
|
'bufferutil',
|
|
|
|
'utf-8-validate',
|
|
|
|
],
|
2025-01-07 11:10:28 +08:00
|
|
|
define: {
|
|
|
|
__VERSION__: version,
|
|
|
|
},
|
2025-02-27 11:33:49 +08:00
|
|
|
sourceMap: true,
|
2024-07-23 16:25:11 +08:00
|
|
|
},
|
|
|
|
});
|