-
Notifications
You must be signed in to change notification settings - Fork 4
/
rollup.config.mjs
65 lines (60 loc) · 1.66 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
import peerDepsExternal from "rollup-plugin-peer-deps-external";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import postcss from "rollup-plugin-postcss";
import tailwindcss from "tailwindcss";
import autoprefixer from "autoprefixer";
import svgr from "@svgr/rollup";
import { terser } from "rollup-plugin-terser";
import glob from "glob";
const isProduction = process.env.NODE_ENV === "production";
const componentPaths = glob.sync("src/**/*.{ts,tsx,css}", {
ignore: ["src/**/stories/**", "src/**/*.stories.tsx", "src/**/*.stories.ts"],
});
const mainConfig = {
input: {
...componentPaths.reduce((entries, filePath) => {
const entryName = filePath
.replace("src/", "")
.replace(/\.(ts|tsx|js)$/, "");
entries[entryName] = filePath;
return entries;
}, {}),
},
output: [
{
dir: "dist",
format: "cjs",
entryFileNames: "[name].js",
sourcemap: true,
},
{
dir: "dist",
format: "esm",
entryFileNames: "[name].js",
sourcemap: true,
},
],
plugins: [
peerDepsExternal(),
resolve(),
commonjs(),
typescript({
tsconfig: "./tsconfig.json",
declaration: true,
declarationDir: "dist/types",
outDir: null,
}),
postcss({
extensions: [".css"],
plugins: [tailwindcss, autoprefixer],
extract: true,
}),
svgr(),
isProduction && terser(), // 프로덕션 빌드에서만 terser 사용
],
external: ["telejson", "react", "react-dom", /^@storybook\//],
};
const configList = [mainConfig];
export default configList;