feat(cli): bump vite 4.2, esbuild 0.17 (#11682)

This commit is contained in:
neverland
2023-03-19 09:21:15 +08:00
committed by GitHub
parent 1d5b37930a
commit e6575ae47b
7 changed files with 136 additions and 110 deletions
+25 -8
View File
@@ -1,13 +1,11 @@
const { build } = require('esbuild');
const { build, context } = require('esbuild');
function bundleBundle(format) {
async function bundle(format) {
const ext = format === 'esm' ? '.mjs' : '.js';
const outfile = `dist/index.${format}${ext}`;
const finish = () => console.log('Build finished:', outfile);
const onRebuild = (error) => (error ? console.log(error) : finish());
build({
watch: process.argv.includes('-w') && { onRebuild },
const options = {
format,
bundle: true,
target: ['chrome53'],
@@ -16,8 +14,27 @@ function bundleBundle(format) {
charset: 'utf8',
external: ['vue', 'vant'],
entryPoints: ['./src/index.ts'],
}).then(finish);
};
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();
}
}
bundleBundle('esm');
bundleBundle('cjs');
bundle('esm');
bundle('cjs');
+1 -1
View File
@@ -37,7 +37,7 @@
"author": "chenjiahan",
"license": "MIT",
"devDependencies": {
"esbuild": "^0.16.10",
"esbuild": "^0.17.12",
"release-it": "^15.4.1",
"rimraf": "^4.0.4",
"typescript": "^5.0.2",