| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import { defineConfig, loadEnv } from 'vite'
- import path from 'path'
- import createVitePlugins from './vite/plugins'
- import * as fs from "node:fs";
- // https://vitejs.dev/config/
- let dev = {
- // shaoyang: `http://42.48.99.5:20002`
- // shaoyang: `http://192.168.110.235:20002`
- shaoyang: `https://192.168.110.13:20002`
- }
- export default defineConfig(({ mode, command }) => {
- const env = loadEnv(mode, process.cwd())
- const { VITE_APP_ENV } = env
- return {
- // base: VITE_APP_ENV === 'production' ? '/qyxyfjflgl/' : '/',
- base: '/qyxyfjflgl/',
- plugins: createVitePlugins(env, command === 'build'),
- resolve: {
- // https://cn.vitejs.dev/config/#resolve-alias
- alias: {
- // 设置路径
- '~': path.resolve(__dirname, './'),
- // 设置别名
- '@': path.resolve(__dirname, './src')
- },
- // https://cn.vitejs.dev/config/#resolve-extensions
- extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
- },
- // vite 相关配置
- server: {
- port: 8081,
- host: true,
- open: true,
- https: {
- key: fs.readFileSync('C:/Users/hxb/Desktop/证书/huaihua.gov.cn/PEM_NGINX/_.huaihua.gov.cn.key'),
- cert: fs.readFileSync('C:/Users/hxb/Desktop/证书/huaihua.gov.cn/PEM_NGINX/_.huaihua.gov.cn.crt')
- },
- proxy: {
- // https://cn.vitejs.dev/config/#server-proxy
- '/dev-api': {
- target: dev.shaoyang,
- changeOrigin: true,
- rewrite: (p) => p.replace(/^\/dev-api/, '')
- }
- }
- },
- //fix:error:stdin>:7356:1: warning: "@charset" must be the first rule in the file
- css: {
- postcss: {
- plugins: [
- {
- postcssPlugin: 'internal:charset-removal',
- AtRule: {
- charset: (atRule) => {
- if (atRule.name === 'charset') {
- atRule.remove()
- }
- }
- }
- }
- ]
- }
- }
- }
- })
|