vite.config.ts个人配置
import { defineConfig, loadEnv } from 'vite'; import vue from '@vitejs/plugin-vue'; import { resolve } from 'path'; import vueJsx from '@vitejs/plugin-vue-jsx'; export default ({ mode }) => defineConfig({ mode: loadEnv(mode, process.cwd()).VITE_APP_MODE, css: { postcss: { plugins: [ // 前缀追加 require('autoprefixer')({ overrideBrowserslist: [ 'Android 4.1', // 'iOS 7.1', 'Chrome > 31', 'ff > 31', '> 1%' ], grid: true }) ] }, preprocessorOptions: { scss: { additionalData: `@import "./src/scss/variables.scss";` } } }, esbuild: { jsxFactory: 'h', jsxFragment: 'Fragment' }, server: { open: true, port: 20202 }, build: { terserOptions: { compress: { drop_console: mode === 'production', drop_debugger: mode === 'production' } } }, resolve: { alias: [ { find: /^@\//, replacement: resolve(__dirname, 'src') }, { find: /^@assets/, replacement: resolve(__dirname, 'src/assets') }, { find: /^@components/, replacement: resolve(__dirname, 'src/components') }, { find: /^@hooks/, replacement: resolve(__dirname, 'src/hooks') }, { find: /^@scss/, replacement: resolve(__dirname, 'src/scss') }, { find: /^@plugins/, replacement: resolve(__dirname, 'src/plugins') }, { find: /^@views/, replacement: resolve(__dirname, 'src/views') } ], extensions: ['ts', 'js', 'json'] }, plugins: [ vue(), vueJsx({ transformOn: true, mergeProps: true }) ] });