forked from jdf2e/nutui-react
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
40 lines (36 loc) · 1.2 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
38
39
40
import { defineConfig } from 'vite'
import reactRefresh from '@vitejs/plugin-react'
import path from 'path'
import atImport from 'postcss-import'
const projectID = process.env.VITE_APP_PROJECT_ID
const { resolve } = path
let fileStr = `@import "@/styles/variables.scss";@import "@/sites/assets/styles/variables.scss";@import '@/styles/theme-default.scss';\n`
if (projectID) {
fileStr = `@import '@/styles/variables-${projectID}.scss';\n@import "@/sites/assets/styles/variables.scss";\n@import '@/styles/font-${projectID}/iconfont.css';\n@import '@/styles/theme-${projectID}.scss';\n`
}
// https://vitejs.dev/config/
export default defineConfig({
server: {
host: '0.0.0.0',
},
base: '/react/',
resolve: {
alias: [{ find: '@', replacement: resolve(__dirname, './src') }],
},
css: {
preprocessorOptions: {
scss: {
// example : additionalData: `@import "./src/design/styles/variables";`
// dont need include file extend .scss
additionalData: fileStr,
},
},
postcss: {
plugins: [
atImport({ path: path.join(__dirname, 'src') }),
// process.env.VITE_RTL === 'rtl' ? rtl() : () => {},
],
},
},
plugins: [reactRefresh()],
})