mirror of
https://github.com/web-infra-dev/midscene.git
synced 2025-07-04 15:41:20 +00:00

* fix(core): bundle template content into core package * fix(core): lint * docs: add bundler mode error msg * fix(core): ci --------- Co-authored-by: zhouxiao.shaw <zhouxiao.shaw@bytedance.com>
61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { defineConfig } from '@rslib/core';
|
|
import { version } from './package.json';
|
|
|
|
const copyReportTemplate = () => ({
|
|
name: 'copy-report-template',
|
|
setup(api) {
|
|
api.onAfterBuild(({ compiler }) => {
|
|
const shebang = '#!/usr/bin/env node\n';
|
|
|
|
// Add shebang to index.cjs
|
|
const cjsPath = path.join(__dirname, 'dist', 'index.cjs');
|
|
if (fs.existsSync(cjsPath)) {
|
|
const content = fs.readFileSync(cjsPath, 'utf-8');
|
|
if (!content.startsWith(shebang)) {
|
|
fs.writeFileSync(cjsPath, shebang + content);
|
|
}
|
|
}
|
|
|
|
// Add shebang to index.js
|
|
const jsPath = path.join(__dirname, 'dist', 'index.js');
|
|
if (fs.existsSync(jsPath)) {
|
|
const content = fs.readFileSync(jsPath, 'utf-8');
|
|
if (!content.startsWith(shebang)) {
|
|
fs.writeFileSync(jsPath, shebang + content);
|
|
}
|
|
}
|
|
});
|
|
},
|
|
});
|
|
|
|
export default defineConfig({
|
|
source: {
|
|
define: {
|
|
__VERSION__: `'${version}'`,
|
|
},
|
|
entry: {
|
|
index: './src/index.ts',
|
|
},
|
|
},
|
|
output: {
|
|
copy: [
|
|
{ from: path.join(__dirname, '../../apps/site/docs/en/API.mdx') },
|
|
{ from: path.join(__dirname, './src/playwright-example.txt') },
|
|
],
|
|
},
|
|
lib: [
|
|
{
|
|
format: 'esm',
|
|
syntax: 'es2021',
|
|
dts: true,
|
|
},
|
|
{
|
|
format: 'cjs',
|
|
syntax: 'es2021',
|
|
},
|
|
],
|
|
plugins: [copyReportTemplate()],
|
|
});
|