-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
45 lines (40 loc) · 1014 Bytes
/
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
import path from 'path'
import fs from 'fs'
import _ from 'lodash'
import { babel } from '@rollup/plugin-babel'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import babelConfig from './babel.config.cjs'
const pkg = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), './package.json')))
const name = pkg.name.startsWith('@domp') ? pkg.name.match(/^@domp\/(.*)$/)[1] : pkg.name
const umdGlobal = _.camelCase(name)
const plugins = [
babel({
...babelConfig,
babelHelpers: 'bundled',
exclude: 'node_modules/**/*',
}),
nodeResolve(),
]
const configs = [{
plugins,
input: 'src/index.js',
output: {
file: `dist/${name}.js`,
format: 'umd',
name: `$${umdGlobal}`,
sourcemap: true,
},
}]
if (fs.existsSync(path.join(process.cwd(), 'src/fp.js'))) {
configs.push({
plugins,
input: 'src/fp.js',
output: {
file: `dist/${name}.fp.js`,
format: 'umd',
name: `$${umdGlobal}Fp`,
sourcemap: true,
},
})
}
export default configs