-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.base.js
42 lines (38 loc) · 1.05 KB
/
rollup.config.base.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
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import typescript from 'rollup-plugin-typescript2'
import pkg from './package.json'
const external = [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})]
const plugins = [
resolve({
browser: true
}),
commonjs({
include: /node_modules/,
}),
typescript({ useTsconfigDeclarationDir: false }),
]
/**
* 롤업 설정 만들기 함수
* @param {string} moduleFormat es or cjs
* @returns {Object} 롤업 설정
*/
export function createRollupConfig(moduleFormat) {
let format = moduleFormat === 'esm' ? 'es' : moduleFormat
if (format !== 'es' && format !== 'cjs') {
console.warn('invalid module format')
return
}
return {
input: 'src/index.ts',
output: {
dir: `build/${format}`,
format: format,
sourcemap: true,
exports: 'named',
},
preserveModules: false,
plugins,
external,
}
}