-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
86 lines (78 loc) · 2.27 KB
/
vite.config.ts
File metadata and controls
86 lines (78 loc) · 2.27 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react-swc";
import { defineConfig } from "vite";
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import fs from 'node:fs'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
// Custom plugin to suppress CSS parsing warnings
const suppressCSSWarnings = {
name: 'suppress-css-warnings',
apply: 'build',
enforce: 'post',
configResolved() {
// Store original console.log
const originalLog = console.log
const originalWarn = console.warn
// Override console methods to filter warnings
console.log = function(...args) {
const message = args.join(' ')
if (!message.includes('Unexpected token ParenthesisBlock') && !message.includes('Found 3 warnings')) {
originalLog.apply(console, args)
}
}
console.warn = function(...args) {
const message = args.join(' ')
if (!message.includes('Unexpected token ParenthesisBlock') && !message.includes('Found 3 warnings')) {
originalWarn.apply(console, args)
}
}
}
}
// Custom plugin to copy staticwebapp.config.json to dist folder
const copyStaticWebAppConfig = {
name: 'copy-staticwebapp-config',
apply: 'build',
closeBundle() {
const source = path.resolve(__dirname, 'staticwebapp.config.json')
const dest = path.resolve(__dirname, 'dist', 'staticwebapp.config.json')
// Ensure the source file exists
if (!fs.existsSync(source)) {
console.warn('⚠ Warning: staticwebapp.config.json not found, skipping copy')
return
}
// Ensure the dist directory exists
const distDir = path.dirname(dest)
if (!fs.existsSync(distDir)) {
fs.mkdirSync(distDir, { recursive: true })
}
fs.copyFileSync(source, dest)
console.log('✓ Copied staticwebapp.config.json to dist/')
}
}
// https://vite.dev/config/
export default defineConfig({
plugins: [
react(),
tailwindcss(),
suppressCSSWarnings,
copyStaticWebAppConfig,
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src')
}
},
server: {
port: 5173,
proxy: {
'/api': {
target: 'http://localhost:7071',
changeOrigin: true,
}
}
},
build: {
cssMinify: 'esbuild',
},
});