-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
103 lines (100 loc) · 2.29 KB
/
Copy pathrollup.config.mjs
File metadata and controls
103 lines (100 loc) · 2.29 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import replace from "@rollup/plugin-replace";
import terser from "@rollup/plugin-terser";
import typescript from "@rollup/plugin-typescript";
import del from "rollup-plugin-delete";
import dts from "rollup-plugin-dts";
import external from "rollup-plugin-peer-deps-external";
import postcss from "rollup-plugin-postcss";
export default [
// Main React Component Bundle
{
input: "src/index.ts",
output: [
{
file: "dist/index.esm.js",
format: "esm",
banner: "'use client';",
},
{
file: "dist/index.js",
format: "cjs",
banner: "'use client';",
},
],
external: [
"react",
"react-dom",
"react-hook-form",
/^react\/.*/,
/^react-dom\/.*/,
/^react-hook-form\/.*/,
],
plugins: [
del({ targets: "dist/*" }),
resolve({
preferBuiltins: false,
browser: true,
}),
commonjs(),
typescript({
tsconfig: "./tsconfig.json",
declaration: false,
}),
postcss({
extract: false,
inject: true,
}),
replace({
preventAssignment: true,
"process.env.NODE_ENV": JSON.stringify("production"),
}),
terser({
compress: { directives: false },
}),
],
},
// Web Component Bundle (bundled React)
{
input: "src/WebComponentWrapper.tsx",
output: {
file: "dist/webcomponent.js",
format: "iife",
name: "StackOneHubWebComponent",
sourcemap: true,
},
plugins: [
resolve({
preferBuiltins: false,
browser: true,
exportConditions: ["browser", "module", "import", "default"],
}),
commonjs(),
typescript({
tsconfig: "./tsconfig.json",
declaration: false,
}),
postcss({
extract: false,
inject: true,
}),
replace({
preventAssignment: true,
"process.env.NODE_ENV": JSON.stringify("production"),
}),
terser({
compress: { directives: false },
}),
],
},
// TypeScript declarations
{
input: "src/index.ts",
output: {
file: "dist/index.d.ts",
format: "es",
},
plugins: [dts()],
},
];