This repository was archived by the owner on Mar 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
75 lines (63 loc) · 1.75 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
67
68
69
70
71
72
73
74
75
import fs from 'fs'
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import pkg from './package.json'
import babel from 'rollup-plugin-babel'
import uglify from '@lopatnov/rollup-plugin-uglify'
const extensions = ['.js', '.jsx', '.ts', '.tsx']
const firstMatch = (baseFileName) =>
extensions
.reduce((acc, ex) => {
const isMatch = fs.existsSync(baseFileName + ex)
return isMatch ? [...acc, baseFileName + ex] : acc
}, [])
.shift()
const input = firstMatch('src/main')
// TBD: use pkg.name => camel-case ?
const name = 'CryptrSpa'
const isProduction = process.env.NODE_ENV === 'production'
export default {
input,
// Specify here external modules which you don't want to include in your bundle (for instance: 'lodash', 'moment' etc.)
// https://rollupjs.org/guide/en#external-e-external
// TBD extract from package deps?
external: [],
plugins: [
// Allows node_modules resolution
// resolve({ extensions }),
resolve({
extensions: extensions,
preferBuiltins: true,
browser: true,
}),
// Allow bundling cjs modules. Rollup doesn't understand cjs
commonjs(),
// Compile TypeScript/JavaScript files
babel({
extensions,
include: ['src/**/*'],
exclude: ['node_modules/**', '**/snapshots/**', `**/*.{test,spec}.{${extensions.join(',')}}`],
runtimeHelpers: true,
}),
// Minify js
uglify(),
],
output: [
{
file: pkg.module,
format: 'esm',
},
{
file: pkg.browser,
format: 'umd',
name: name,
},
],
onwarn: function (warning, handler) {
// Here to disable Es Cookie warning
if (warning.code === 'THIS_IS_UNDEFINED') {
return
}
handler(warning)
},
}