-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathvite.config.js
More file actions
66 lines (64 loc) · 1.71 KB
/
vite.config.js
File metadata and controls
66 lines (64 loc) · 1.71 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import react from "@vitejs/plugin-react-swc";
import { defineConfig, loadEnv } from "vite";
import autoprefixer from "autoprefixer";
import vitePluginDetectInput from "./vitePluginDetectInput";
const env = loadEnv("all", process.cwd());
export default defineConfig({
plugins: [
vitePluginDetectInput({
regex: /vite_import\(["'](.+)["']\)/g,
glob: "./templates/**/*.html",
}),
react(),
],
server: {
port: env?.VITE_PORT || 5173,
host: true,
cors: {
origin: [
"http://localhost:8004",
"http://127.0.0.1:8004",
"http://0.0.0.0:8004",
], // needed for backend integration with Flask
},
},
css: {
preprocessorOptions: {
scss: {
quietDeps: true,
silenceDeprecations: ["import", "global-builtin"],
},
},
postcss: {
plugins: [autoprefixer()],
map: false,
},
},
define: {
global: "globalThis", // in dev mode "randomstring" uses `global` rather than `globalThis`
},
resolve: {
alias: [
// by default react-components exports a CJS module that can't be tree-shaken, we consume the ESM instead
{
find: /^@canonical\/react-components$/,
replacement: "@canonical/react-components/dist/esm",
},
],
},
base: "./", // use the script's URL path as base when loading assets in dynamic imports
build: {
manifest: true,
modulePreload: false,
emptyOutDir: true,
sourcemap: "hidden",
outDir: env?.VITE_OUTDIR || "static/js/dist/vite",
rollupOptions: {
output: {
entryFileNames: `[name]--[hash].js`,
chunkFileNames: `chunks/[name]--[hash].js`,
assetFileNames: `assets/[name]--[hash][extname]`,
},
},
},
});