-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
175fe91
commit 080b680
Showing
4 changed files
with
44 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters