-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.js
57 lines (52 loc) · 1.26 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
49
50
51
52
53
54
55
56
57
/* eslint-disable node/no-unpublished-require */
require('./lib/env-config')
const commonjs = require('rollup-plugin-commonjs')
const json = require('rollup-plugin-json')
const pkg = require('./package.json')
const recursiveReaddir = require('recursive-readdir')
const resolve = require('rollup-plugin-node-resolve')
const { terser } = require('rollup-plugin-terser')
const dependencies = Object.keys(pkg.dependencies)
const devDependencies = Object.keys(pkg.devDependencies).map(
(dev) => `node_modules/${dev}/**`
)
const includeFilesThatAreNotTests = (async () => {
let files = null
try {
files = await recursiveReaddir('./lib').filter(
(filePath) => !filePath.includes('__tests__')
)
} catch (err) {
files = []
}
return files
})()
const rollupConfig = {
input: 'lib/index.js',
output: [
{
compact: true,
file: pkg.main,
format: 'cjs',
interop: false
}
],
plugins: [
json({
compact: true,
exclude: devDependencies,
indent: ' ',
preferConst: true
}),
resolve({
mainFields: ['module', 'main'],
only: includeFilesThatAreNotTests
}),
commonjs({
exclude: devDependencies
}),
terser()
],
external: dependencies
}
module.exports = rollupConfig