vite.config.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { fileURLToPath, URL } from "node:url";
  2. import eslintPlugin from 'vite-plugin-eslint';
  3. import WindiCSS from 'vite-plugin-windicss'
  4. import path from "path"
  5. import { defineConfig } from "vite";
  6. import legacy from "@vitejs/plugin-legacy";
  7. import vue2 from "@vitejs/plugin-vue2";
  8. // https://vitejs.dev/config/
  9. export default defineConfig({
  10. plugins: [
  11. vue2(),
  12. WindiCSS(),
  13. legacy({
  14. targets: ["ie >= 11"],
  15. additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
  16. }),
  17. eslintPlugin({
  18. include: ['src/**/*.js', 'src/**/*.vue', 'src/*.js', 'src/*.vue'],
  19. }),
  20. ],
  21. css: {
  22. preprocessorOptions: {
  23. scss: {
  24. additionalData:'@import "./src/assets/style/main.scss";'
  25. }
  26. }
  27. },
  28. resolve: {
  29. alias: {
  30. "@": path.resolve(__dirname, 'src'),
  31. },
  32. },
  33. server: {
  34. // 是否开启 https
  35. https: false,
  36. // 端口号
  37. port: 3000,
  38. // 监听所有地址
  39. host: "0.0.0.0",
  40. // 服务启动时是否自动打开浏览器
  41. open: true,
  42. },
  43. build: {
  44. // 设置最终构建的浏览器兼容目标
  45. target: "es2015",
  46. // 构建后是否生成 source map 文件
  47. sourcemap: false,
  48. // chunk 大小警告的限制(以 kbs 为单位)
  49. chunkSizeWarningLimit: 2000,
  50. // 启用/禁用 gzip 压缩大小报告
  51. reportCompressedSize: false,
  52. },
  53. });