-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathvite.config.js
67 lines (64 loc) · 1.82 KB
/
vite.config.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
import react from "@vitejs/plugin-react";
import svgrPlugin from "vite-plugin-svgr";
import global from "rollup-plugin-external-globals";
import { buildVars } from "../dev-utils/buildVars.js";
import injectCss from "vite-plugin-css-injected-by-js";
import { getLibNames, getAllLibGlobalVarNames } from "../dev-utils/external.js";
import paths from "./paths.js";
import { defineConfig } from "vite";
import { readJson } from "../dev-utils/util.js";
const isProduction = process.env.NODE_ENV === "production";
const packageJson = readJson(paths.appPackageJson);
const define = {};
buildVars.forEach(({ name, defaultValue }) => {
define[name] = JSON.stringify(process.env[name] || defaultValue);
});
export default defineConfig({
define: {
...define,
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "development"),
__LOWCODER_ORG__: JSON.stringify({}),
},
assetsInclude: ["**/*.md"],
resolve: {
extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json"],
},
build: {
target: "es2020",
cssTarget: "chrome87",
outDir: paths.appOutPath,
emptyOutDir: true,
lib: {
formats: ["es"],
entry: paths.compsIndexJs,
fileName: "index",
},
rollupOptions: {
external: getLibNames(),
output: {
chunkFileNames: "[hash].js",
},
},
},
plugins: [
react({
babel: {
compact: false,
parserOpts: {
plugins: ["decorators-legacy"],
},
},
}),
svgrPlugin({
svgrOptions: {
exportType: "named",
prettier: false,
svgo: false,
titleProp: true,
ref: true,
},
}),
isProduction && global(getAllLibGlobalVarNames(), { exclude: [/\.css$/] }),
isProduction && injectCss({ styleId: `${packageJson.name}-${packageJson.version}` }),
].filter(Boolean),
});