Skip to content

Commit 53442b1

Browse files
author
Herve Tribouilloy
committed
Simplified vite config to enable production to work in CI/CD mode
1 parent 5015158 commit 53442b1

1 file changed

Lines changed: 24 additions & 43 deletions

File tree

vite_project/vite.config.ts

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,31 @@
1-
import {defineConfig, loadEnv} from "vite";
1+
import {defineConfig} from "vite";
22
import react from "@vitejs/plugin-react-swc";
33
import pkg from './package.json';
44

5-
console.log('AUTH BRIDGE TARGET:', process.env.VITE_AUTH_BRIDGE_TARGET);
6-
7-
export default defineConfig(({ mode }) => {
8-
const env = loadEnv(mode, process.cwd(), '');
9-
10-
const authBridgeTarget = env.VITE_AUTH_BRIDGE_TARGET;
11-
12-
if (mode === 'development' && !authBridgeTarget) {
13-
throw new Error(
14-
'VITE_AUTH_BRIDGE_TARGET is required in development mode'
15-
);
16-
}
17-
18-
return {
19-
server: {
20-
proxy: {
21-
'/auth': {
22-
target: authBridgeTarget,
23-
changeOrigin: true,
24-
},
25-
},
26-
},
27-
plugins: [react()],
28-
define: {
29-
'process.env': {},
5+
export default defineConfig({
6+
plugins: [react()],
7+
server: {
8+
allowedHosts: ['widget-booking.local'],
9+
},
10+
define: {
11+
'process.env': {},
12+
},
13+
build: {
14+
outDir: "../www",
15+
emptyOutDir: false,
16+
lib: {
17+
entry: "src/widget.ts",
18+
name: "WidgetBookingSystem",
19+
fileName: () => `widget-booking@${pkg.version}.iife.js`,
20+
formats: ["iife"],
3021
},
31-
build: {
32-
outDir: "../www",
33-
emptyOutDir: false,
34-
lib: {
35-
entry: "src/widget.ts",
36-
name: "WidgetBookingSystem",
37-
fileName: () => `widget-booking@${pkg.version}.iife.js`,
38-
formats: ["iife"],
22+
rollupOptions: {
23+
output: {
24+
inlineDynamicImports: true,
25+
assetFileNames: "widget-booking.[ext]",
3926
},
40-
rollupOptions: {
41-
output: {
42-
inlineDynamicImports: true,
43-
assetFileNames: "widget-booking.[ext]",
44-
},
45-
},
46-
minify: true,
47-
sourcemap: false
48-
}
27+
},
28+
minify: true,
29+
sourcemap: false
4930
}
5031
});

0 commit comments

Comments
 (0)