-
Notifications
You must be signed in to change notification settings - Fork 29
/
rollup.config.mjs
82 lines (75 loc) · 1.6 KB
/
rollup.config.mjs
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 process from "process";
import os from "os";
import resolve from "@rollup/plugin-node-resolve";
import css from "rollup-plugin-import-css";
import terser from "@rollup/plugin-terser";
import serve from "rollup-plugin-serve";
import livereload from "rollup-plugin-livereload";
import image from "@rollup/plugin-image";
import { string } from "rollup-plugin-string";
const pkg = {
main: "dist/three-cad-viewer.js",
module: "dist/three-cad-viewer.esm.js",
};
function addMin(name) {
return `${name.slice(0, -3)}.min.js`;
}
const umdName = "CadViewer";
const default_plugins = [
resolve(),
css({ output: "three-cad-viewer.css" }),
image(),
string({ include: "src/index.html" })
];
var config;
if (process.env.BUILD === "production") {
config = [
{
input: "src/index.js",
plugins: [...default_plugins],
output: [
{
format: "es",
file: pkg.module,
},
{
format: "umd",
name: umdName,
file: pkg.main,
},
],
},
{
input: "src/index.js",
plugins: [...default_plugins, terser()],
output: [
{
format: "es",
file: addMin(pkg.module),
},
{
format: "umd",
name: umdName,
file: addMin(pkg.main),
},
],
},
];
} else {
config = {
input: "src/index.js",
plugins: [
...default_plugins,
serve({
host: "localhost",
port: 8082,
}),
livereload(),
],
output: {
format: "es",
file: pkg.module,
},
};
}
export default config;