-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-module.js
35 lines (31 loc) · 1016 Bytes
/
build-module.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const rollup = require( 'rollup' ).rollup;
const resolve = require( '@rollup/plugin-node-resolve' ).nodeResolve;
const esbuild = require( 'rollup-plugin-esbuild' ).default;
const banner = require( './constants/banner' );
const babel = require( '@rollup/plugin-babel' );
const path = require( 'path' );
const name = 'splide';
function buildModule( type ) {
return rollup( {
input: './src/js/index.ts',
plugins: [
resolve(),
esbuild(),
babel.getBabelOutputPlugin( {
configFile: path.resolve( __dirname, '../.babelrc' ),
allowAllFormats: true,
} ),
],
} ).then( bundle => {
return bundle.write( {
banner,
file : `./dist/js/${ name }.${ type }.js`,
format : type,
sourcemap: false,
exports : 'named',
} );
} );
}
Promise.all( [ buildModule( 'cjs' ), buildModule( 'esm' ) ] ).catch( e => console.error( e ) );
exports.buildCjs = () => buildModule( 'cjs' );
exports.buildEsm = () => buildModule( 'esm' );