-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.backup.js
68 lines (67 loc) · 2.22 KB
/
vite.config.backup.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
import { defineConfig } from "vite";
import { extname, relative } from "path";
import { fileURLToPath } from "node:url";
import { glob } from "glob";
import { visualizer } from "rollup-plugin-visualizer";
import { libInjectCss } from "vite-plugin-lib-inject-css";
import dts from "vite-plugin-dts";
import svgr from "vite-plugin-svgr";
import react from "@vitejs/plugin-react";
import postcssNesting from "postcss-nesting";
import autoprefixer from "autoprefixer";
import pkg from "./package.json";
/** @type {import('vite').UserConfig} */
export default defineConfig({
css: {
postcss: {
plugins: [postcssNesting, autoprefixer],
},
},
build: {
cssMinify: false,
cssCodeSplit: true,
lib: {
entry: "src/index.tsx",
name: pkg.name,
},
},
plugins: [
svgr(),
react({
babel: {
presets: [["@babel/preset-env", { modules: false }], ["@babel/preset-react"]],
plugins: [["transform-react-remove-prop-types", { removeImport: true }]],
},
}),
libInjectCss({
// This config should ideally be on top but libInjectCss for some reasons bundles
// extra output files if options are not passed here
rollupOptions: {
input: Object.fromEntries(
glob
.sync("src/**/*.{js,jsx,ts,tsx}", { ignore: "src/**/*.stories.{js,jsx,ts,tsx}" })
.map((file) => [
relative("src", file.slice(0, file.length - extname(file).length)),
fileURLToPath(new URL(file, import.meta.url)),
])
),
output: [
{
format: "es",
entryFileNames: "[name].js",
},
{
format: "cjs",
entryFileNames: "[name].cjs",
},
],
external: [...Object.keys(pkg.peerDependencies)],
},
}),
dts(),
{
...visualizer(),
apply: "build",
},
],
});