-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
45 lines (44 loc) · 1.63 KB
/
vite.config.ts
File metadata and controls
45 lines (44 loc) · 1.63 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
import { defineConfig, splitVendorChunkPlugin } from "vite";
import svgr from "vite-plugin-svgr";
import { spiffThemePlugin } from "@spiffcommerce/theme-bridge";
import { configurationSchema } from "./src/configurationSchema";
import { existsSync, readFileSync } from "fs";
// https://vitejs.dev/config/
export default defineConfig((env) => {
const configurationPath = `./.env.${env.mode}.json`;
const themeConfiguration = existsSync(configurationPath) ? readFileSync(configurationPath, "utf-8") : undefined;
return {
base: "",
define: {
__LOCAL_DEV_CONFIGURATION__: themeConfiguration,
"globalThis.__DEV__": JSON.stringify(false),
},
plugins: [
svgr(),
splitVendorChunkPlugin(),
spiffThemePlugin({ configurationSchema, includePreloadChunks: false }),
],
build: {
emptyOutDir: true,
rollupOptions: {
output: {
entryFileNames: "assets/[name].js",
chunkFileNames: "assets/[name].chunk.js",
assetFileNames: "assets/[name].[ext]",
manualChunks(id, _meta) {
if (!id.includes("node_modules")) return;
if (id.includes("@spiffcommerce/preview")) return "vendor-spiffcommerce-preview";
if (id.includes("@spiffcommerce")) return "vendor-spiffcommerce";
return;
},
},
},
},
server: {
port: 3333,
},
preview: {
port: 3334,
},
};
});