vite.config.js 1.4 KB

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