chore(vant-use): use Rslib to build (#13250)

This commit is contained in:
neverland
2024-12-08 09:32:00 +08:00
committed by GitHub
parent 3884730c4e
commit 8d17b4076d
6 changed files with 24 additions and 15 deletions
+40
View File
@@ -0,0 +1,40 @@
const { build, context } = require('esbuild');
async function bundle(format) {
const ext = format === 'esm' ? '.mjs' : '.js';
const outfile = `dist/index.${format}${ext}`;
const finish = () => console.log('Build finished:', outfile);
const options = {
format,
bundle: true,
target: ['chrome53'],
outfile,
// preserve Chinese character
charset: 'utf8',
external: ['vue', 'vant'],
entryPoints: ['./src/index.ts'],
};
if (process.argv.includes('-w')) {
const loggerPlugin = {
name: 'loggerPlugin',
setup(build) {
build.onEnd(finish);
},
};
const ctx = await context({
...options,
plugins: [loggerPlugin],
});
await ctx.watch();
} else {
await build(options);
finish();
}
}
bundle('esm');
bundle('cjs');