generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
37 lines (36 loc) · 1.04 KB
/
vite.config.ts
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
import { defineConfig, loadEnv } from "vite";
import httpAuth from "vite-plugin-http-basic-auth"
import react from "@vitejs/plugin-react-swc";
import path from "path";
import { componentTagger } from "lovable-tagger";
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
// httpAuth plugin expects env variables at vite build time
// - need to ensure these are in place in pipeline
// & maybe k8s config map for cloud platform deployments
return ({
server: {
host: "::",
port: 3000,
},
plugins: [
react(),
mode === 'development' &&
componentTagger(),
httpAuth([{
username: env.VITE_AUTH_USERNAME_1,
password: env.VITE_AUTH_PASSWORD_1
}], {
realm: env.VITE_AUTH_REALM,
useInServer: true, // True by default
useInPreview: true, // True by default
})
].filter(Boolean),
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
})
});