-
Notifications
You must be signed in to change notification settings - Fork 137
/
rollup.config.js
60 lines (54 loc) · 2.11 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
58
59
60
import typescript from '@rollup/plugin-typescript'
import dts from 'rollup-plugin-dts'
import terser from '@rollup/plugin-terser'
const config = ({ format, input, output, name, dir, extension = 'js', exports = undefined }) => {
const shouldMinify = process.env.MINIFY === 'true' && output !== 'dts'
return {
input,
output: {
sourcemap: output !== 'dts',
dir: `dist/${dir || format}`,
exports,
format,
name,
entryFileNames: shouldMinify ? `[name].min.${extension}` : `[name].${extension}`,
plugins: shouldMinify
? [terser({
mangle: {
properties: {
regex: /^_/
}
}
})]
: []
},
plugins: [output === 'dts' ? dts() : typescript()]
}
}
const benchmarks = {
input: 'benchmarks/index.js',
output: {
sourcemap: true,
dir: 'benchmarks/dist',
format: 'commonjs',
entryFileNames: '[name].cjs',
plugins: []
},
external: ['benchmark'],
plugins: [typescript()]
}
export default process.env.BENCHMARKS === 'true' ? [benchmarks] : [
// Main (MiniSearch)
config({ format: 'es', input: 'src/index.ts', output: 'es6' }),
config({ format: 'cjs', input: 'src/index.ts', output: 'cjs', dir: 'cjs', extension: 'cjs', exports: 'default' }),
config({ format: 'umd', input: 'src/index.ts', output: 'umd', name: 'MiniSearch' }),
// SearchableMap
config({ format: 'es', input: 'src/SearchableMap/SearchableMap.ts', output: 'es6' }),
config({ format: 'cjs', input: 'src/SearchableMap/SearchableMap.ts', output: 'cjs', dir: 'cjs', extension: 'cjs', exports: 'default' }),
config({ format: 'umd', input: 'src/SearchableMap/SearchableMap.ts', output: 'umd', name: 'MiniSearch' }),
// Type declarations
config({ format: 'es', input: 'src/index.ts', output: 'dts', extension: 'd.ts' }),
config({ format: 'es', input: 'src/SearchableMap/SearchableMap.ts', output: 'dts', extension: 'd.ts' }),
config({ format: 'cjs', input: 'src/index.ts', output: 'dts', extension: 'd.cts' }),
config({ format: 'cjs', input: 'src/SearchableMap/SearchableMap.ts', output: 'dts', extension: 'd.cts' })
]