vite.config.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import vue from '@vitejs/plugin-vue'
  2. import path from 'path'
  3. import { ConfigEnv, defineConfig, UserConfigExport } from 'vite'
  4. import { viteVConsole } from 'vite-plugin-vconsole'
  5. export default ({ command, mode }: ConfigEnv): UserConfigExport => defineConfig({
  6. base: '/',
  7. css: {
  8. preprocessorOptions: {
  9. scss: {
  10. additionalData: '@import "./src/styles/variables";'
  11. },
  12. }
  13. },
  14. resolve: {
  15. alias: [
  16. {
  17. find: '/@',
  18. replacement: path.resolve(__dirname, './src'),
  19. }
  20. ]
  21. },
  22. server: {
  23. open: true,
  24. host: '0.0.0.0',
  25. port: 8080
  26. },
  27. build: {
  28. target: ['es2015'], // 最低支持 es2015
  29. sourcemap: true
  30. },
  31. plugins: [
  32. vue(),
  33. viteVConsole({
  34. entry: path.resolve(__dirname, './src/main.ts'), // 入口文件
  35. localEnabled: command === 'serve', // serve开发环境下
  36. // enabled: command !== 'serve' || mode === 'test', // 打包环境下/发布测试包,
  37. config: { // vconsole 配置项
  38. maxLogNumber: 1000,
  39. theme: 'light'
  40. }
  41. }),
  42. ],
  43. })