vite.config.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import path from 'path'
  4. export default defineConfig({
  5. base: "./", //设置打包路径
  6. // 打包配置
  7. // build: {
  8. // sourcemap: true,
  9. // outDir: 'distp', // 指定输出路径,要和库的包区分开
  10. // assetsDir: 'static/img/', // 指定生成静态资源的存放路径
  11. // brotliSize: false, // 不统计
  12. // target: 'esnext',
  13. // minify: 'esbuild', // 混淆器,terser构建后文件体积更小
  14. // rollupOptions: {
  15. // output: {
  16. // chunkFileNames: 'static/js/[name]-[hash].js',
  17. // entryFileNames: 'static/js/[name]-[hash].js',
  18. // assetFileNames: 'static/[ext]/[name]-[hash].[ext]'
  19. // },
  20. // }
  21. // },
  22. plugins: [vue()],
  23. resolve: {
  24. alias: {
  25. '@': path.resolve(__dirname, './src') // 设置别名
  26. }
  27. },
  28. server: {
  29. host: '0.0.0.0',
  30. port: 6090, //设置服务启动端口
  31. // //open: true, //设置服务启动时是否自动打开浏览器
  32. // cors: true, //默认启用并允许任何源
  33. // //设置代理
  34. // proxy: {
  35. // '/api': {
  36. // target: 'http://114.242.31.4:6090', //请求的域名地址
  37. // changeOrigin: true, //是否允许跨域代理
  38. // secure: false,
  39. // rewrite: (path) => path.replace(/^\/api/, '') // 重定向地址
  40. // }
  41. // }
  42. },
  43. css: {
  44. preprocessorOptions: {
  45. scss: {
  46. // 关闭编译时 字符编码 报错问题
  47. charset: false,
  48. },
  49. },
  50. },
  51. })