This repository was archived by the owner on Oct 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrollup.config.js
More file actions
82 lines (67 loc) · 1.51 KB
/
Copy pathrollup.config.js
File metadata and controls
82 lines (67 loc) · 1.51 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import path from "path"
import { terser } from "rollup-plugin-terser"
import resolve from "@rollup/plugin-node-resolve"
import babel from "rollup-plugin-babel"
const banner = require("./.bin/banner")
const pkg = require("./package.json")
const absolutePath = dirPath => path.resolve(__dirname, dirPath)
// Base configurations for all bundles
const inputs = {
umd: absolutePath("src/js/index.bundle.js"),
}
const outputs = {
umd: absolutePath("dist/undernet.bundle.js"),
umdMin: absolutePath("dist/undernet.bundle.min.js"),
}
const plugins = [
resolve(),
babel({
exclude: "node_modules/**",
comments: false,
}),
]
/**
* UMD bundle
**/
const umdOutput = {
file: outputs.umd,
// "iife" isn't used in case folks decide they want
// to import the bundle using require/import
format: "umd",
name: pkg.name,
sourcemap: true,
exports: "named",
banner,
}
const umdBundle = {
input: inputs.umd,
output: umdOutput,
plugins,
}
/**
* UMD bundle (minified)
**/
const umdMinOutput = Object.assign({}, umdOutput, {
file: outputs.umdMin,
})
const umdMinPlugins = []
umdMinPlugins.push(
...plugins,
terser({
output: {
comments: (_, comment) => {
const { value, type } = comment
if (type === "comment2") {
return /@preserve|@license|@cc_on/i.test(value)
}
},
},
mangle: { reserved: ["Undernet"] },
})
)
const umdMinBundle = {
input: inputs.umd,
output: umdMinOutput,
plugins: umdMinPlugins,
}
export default [umdBundle, umdMinBundle]