forked from explore-frontend/reborn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
48 lines (44 loc) · 1.22 KB
/
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
44
45
46
47
48
import typescript from 'rollup-plugin-typescript2';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import {join} from 'path';
const PACKAGE_ROOT_PATH = process.cwd();
const OUTPUT_DIR = join(PACKAGE_ROOT_PATH, 'dist');
const PKG_JSON = require(join(PACKAGE_ROOT_PATH, 'package.json'));
const entires = [{
input: join(PACKAGE_ROOT_PATH, 'src/main.ts'),
format: {
dist: 'cjs',
ts: 'es5',
name: 'index.js'
}
}, {
input: join(PACKAGE_ROOT_PATH, 'src/module.ts'),
format: {
dist: 'es',
ts: 'es5',
name: 'index.es.js'
}
}];
export default entires.map(entryConfig => ({
plugins: [
resolve({browser: true}),
commonjs(),
typescript({
clean: true,
tsconfigOverride: {
compilerOptions: {target: entryConfig.format.ts},
},
}),
],
input: entryConfig.input,
external: [...Object.keys(PKG_JSON.peerDependencies || {})],
output: [
{
file: join(OUTPUT_DIR, entryConfig.format.name),
format: entryConfig.format.dist,
sourcemap: true,
name: PKG_JSON.name,
},
],
}));