vite.config.js 1.3 KB

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