-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
66 lines (62 loc) · 1.99 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
61
62
63
64
65
66
import babel from '@rollup/plugin-babel';
import terser from '@rollup/plugin-terser';
import resolve from '@rollup/plugin-node-resolve';
export default {
input: 'src/index.js',
output: [
// UMD Format (with ES5 transpilation)
{
file: 'dist/cookie-watchdog.js',
format: 'umd',
name: 'CookieWatchdog',
sourcemap: true,
},
{
file: 'dist/cookie-watchdog-min.js',
format: 'umd',
name: 'CookieWatchdog',
plugins: [terser()],
},
// ESM Format (no transpilation, ES6+)
{
file: 'dist/cookie-watchdog.esm.js',
format: 'esm',
sourcemap: true,
},
// CJS Format (no transpilation, ES6+)
{
file: 'dist/cookie-watchdog.cjs.js',
format: 'cjs',
sourcemap: true,
},
// IIFE Format (with ES5 transpilation)
{
file: 'dist/cookie-watchdog.iife.js',
format: 'iife',
name: 'CookieWatchdog',
sourcemap: true,
},
// IIFE Format Minified (with ES5 transpilation)
{
file: 'dist/cookie-watchdog.iife-min.js',
format: 'iife',
name: 'CookieWatchdog',
plugins: [terser()],
},
],
plugins: [
// Apply Babel globally for ES5 transpilation
babel({
exclude: 'node_modules/**', // Only transpile files not in node_modules
presets: [
['@babel/preset-env', {
targets: '> 0.25%, not dead', // Target modern browsers for ESM/CJS
useBuiltIns: false, // Do not include polyfills automatically
corejs: false, // We won't handle polyfills here
}],
],
babelHelpers: 'bundled', // Use bundled Babel helpers for transpiling
}),
resolve(), // Helps resolve node modules in browser builds
],
};