build-module.js 589 B

12345678910111213141516171819202122232425
  1. import { rollup } from 'rollup';
  2. import esbuild from 'rollup-plugin-esbuild';
  3. import { BANNER } from './constants/banner.js';
  4. const name = 'splide';
  5. function buildModule( type ) {
  6. return rollup( {
  7. input: './src/js/index.ts',
  8. plugins: [
  9. esbuild(),
  10. ],
  11. } ).then( bundle => {
  12. return bundle.write( {
  13. banner : BANNER,
  14. file : `./dist/js/${ name }.${ type }.js`,
  15. format : type,
  16. sourcemap: false,
  17. exports : 'named',
  18. } );
  19. } );
  20. }
  21. Promise.all( [ buildModule( 'cjs' ), buildModule( 'esm' ) ] ).catch( e => console.error( e ) );