-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathrollup.config.js
43 lines (37 loc) · 920 Bytes
/
rollup.config.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
36
37
38
39
40
41
42
43
/* eslint-env node */
import fs from 'fs';
import path from 'path';
import babel from 'rollup-plugin-babel';
import { terser } from 'rollup-plugin-terser';
const { version, license, name } = require('./package.json');
const licenseData = fs.readFileSync(path.join(process.cwd(), 'LICENSE.md'), {
encoding: 'utf-8',
});
const bannerPlugin = {
banner: `/**
* @license ${name} ${version}
* ${licenseData.split('\n', 1)}
* License: ${license}
*/`,
};
const exportFormat = format => ({
input: `src/tga.js`,
output: {
name: 'TgaLoader',
file: `dist/${format}/tga.js`,
format,
},
plugins: [
bannerPlugin,
format === 'esm' ? null : babel(),
terser({
toplevel: true,
compress: {
unsafe: true,
},
output: { comments: /@license/ },
}),
].filter(v => v),
external: ['src/compiler.js'],
});
export default ['umd', 'cjs', 'esm'].map(exportFormat);