vite.config.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { defineConfig,loadEnv } from 'vite'
  2. import path from 'path'
  3. import vue from '@vitejs/plugin-vue'
  4. import requireTransform from 'vite-plugin-require-transform';
  5. // https://vitejs.dev/config/
  6. export default defineConfig(configEnv =>{
  7. const viteEnv = loadEnv(configEnv.mode, process.cwd())
  8. return {
  9. base: viteEnv.VITE_BASE_URL,
  10. plugins: [
  11. vue(),
  12. requireTransform({
  13. fileRegex: /.js$|.vue$/
  14. }),
  15. ],
  16. server: {
  17. host: '0.0.0.0',
  18. port: 9527,
  19. open: true
  20. },
  21. resolve: {
  22. alias: {
  23. "@": path.resolve(__dirname, "./src"),
  24. "~@": path.resolve(__dirname, "./src"),
  25. }
  26. },
  27. css: {
  28. preprocessorOptions: {
  29. scss: {
  30. additionalData: `@use "./src/styles/index.scss";`,
  31. },
  32. },
  33. },
  34. build: {
  35. outDir: viteEnv.VITE_APP_OUTDIR,
  36. minify: "esbuild",
  37. reportCompressedSize: false,
  38. chunkSizeWarningLimit: 2000,
  39. commonjsOptions: {
  40. ignoreTryCatch: false
  41. },
  42. rollupOptions: {
  43. output: {
  44. chunkFileNames: "static/js/[name][hash].js",
  45. entryFileNames: "static/js/[name][hash].js",
  46. assetFileNames: "static/[ext]/[name][hash].[ext]"
  47. }
  48. }
  49. }
  50. }
  51. })