mirror of
				https://gitee.com/vant-contrib/vant.git
				synced 2025-11-04 04:42:09 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			24 lines
		
	
	
		
			620 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			620 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
const { build } = require('esbuild');
 | 
						|
 | 
						|
function bundleBundle(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 },
 | 
						|
    format,
 | 
						|
    bundle: true,
 | 
						|
    target: ['chrome53'],
 | 
						|
    outfile,
 | 
						|
    // preserve Chinese character
 | 
						|
    charset: 'utf8',
 | 
						|
    external: ['vue'],
 | 
						|
    entryPoints: ['./src/index.ts'],
 | 
						|
  }).then(finish);
 | 
						|
}
 | 
						|
 | 
						|
bundleBundle('esm');
 | 
						|
bundleBundle('cjs');
 |