-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.mjs
63 lines (55 loc) · 1.41 KB
/
rollup.config.mjs
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// rollup.config.js
import typescript from '@rollup/plugin-typescript';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';//Convert CommonJS modules to ES6
import terser from '@rollup/plugin-terser';
import del from 'rollup-plugin-delete';
import { createRequire } from "module";
const pkg = createRequire(import.meta.url)("./package.json");
//FIXME(CC): remove alpha after sdk becomes stable
const banner = `/**
* ${pkg.description} v${pkg.version}-alpha
* @author: ${pkg.author}
* @license: ${pkg.license}
* @repository: ${pkg.repository.url}
* @date: ${new Date().toString()}
**/
`;
let output = [];
if (process.env.NODE_ENV === 'production') {
//TODO(CC): add map for debug
if (process.env.BROWSER === 'true') {
output.push({
file: 'dist/dugon.min.js',
format: 'umd',
name: 'Dugon',
sourcemap: true,
plugins: [terser()],
banner
});
} else {
output.push({
file: 'dist/dugon.js',
format: 'cjs',
});
output.push({
file: 'dist/dugon.mjs',
format: 'esm',
});
}
} else {
output.push({
file: 'dist/dugon.dev.js',
format: 'umd',
name: 'Dugon',
});
}
export default {
input: 'src/dugon.ts',
output,
plugins: [
del({ targets: 'dist/*' }), // This will delete all files in the dist directory
typescript({ tsconfig: './tsconfig.json' }),
resolve(),
commonjs()]
};