拓恒飞手平台网页
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

50 行
1.2KB

  1. import { defineConfig, loadEnv } from 'vite'
  2. import { resolve } from 'path'
  3. import { wrapperEnv } from './build/utils'
  4. import { createVitePlugins } from './build/vite/plugin'
  5. import { createProxy } from './build/vite/proxy'
  6. import { OUTPUT_DIR } from './build/constant'
  7. function pathResolve(dir) {
  8. return resolve(__dirname, '.', dir)
  9. }
  10. export default defineConfig(({ command, mode }) => {
  11. const root = process.cwd()
  12. const isBuild = command === 'build'
  13. const env = loadEnv(mode, process.cwd())
  14. const viteEnv = wrapperEnv(env)
  15. const { VITE_PORT, VITE_PUBLIC_PATH, VITE_PROXY } = viteEnv
  16. return {
  17. root,
  18. base: VITE_PUBLIC_PATH || '/',
  19. plugins: createVitePlugins(viteEnv, isBuild),
  20. lintOnSave: false,
  21. resolve: {
  22. alias: {
  23. '@': pathResolve('src')
  24. }
  25. },
  26. css: {
  27. preprocessorOptions: {
  28. scss: {
  29. additionalData: `@import '@/styles/variables.scss';`
  30. }
  31. }
  32. },
  33. server: {
  34. host: '0.0.0.0',
  35. port: VITE_PORT,
  36. proxy: createProxy(VITE_PROXY)
  37. },
  38. build: {
  39. target: 'es2015',
  40. outDir: OUTPUT_DIR,
  41. brotliSize: false,
  42. chunkSizeWarningLimit: 2000
  43. }
  44. }
  45. })