-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
60 lines (50 loc) · 1.38 KB
/
rollup.config.js
File metadata and controls
60 lines (50 loc) · 1.38 KB
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 babel from '@rollup/plugin-babel';
import { terser } from 'rollup-plugin-terser';
import pkg from './package.json';
const globalName = 'StreamyJsonParser';
const terserOptions = {
compress: {
passes: 3,
drop_console: true,
inline: 3,
dead_code: true
},
mangle: {
toplevel: true,
reserved: []
}
};
const config = {
input: 'src/index.js',
// Exclude external dependencies so they are not included in the bundle (if any)
external: Object.keys(pkg.dependencies || {}),
plugins: [
babel({
babelHelpers: 'bundled',
exclude: 'node_modules/**', // Exclude dependencies from transpilation
}),
],
output: [
// ESM output (for other Node/React/Vue projects)
{
file: pkg.exports['.'].import, // Defined in package.json (e.g., dist/index.esm.js)
format: 'es',
exports: 'default'
},
// Non-minified UMD output (useful for debugging)
{
file: pkg.exports['.'].require, // Defined in package.json (e.g., dist/index.js)
format: 'umd',
name: globalName
},
// Minified UMD output for CDN
{
file: pkg.exports['.'].browser,
format: 'umd',
name: globalName,
sourcemap: true, // Generates a source map for debugging
plugins: [terser(terserOptions)], // Applies Terser minification only to this bundle
},
],
};
export default config;