vite.config.js 922 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import path from 'path';
  2. import vue from '@vitejs/plugin-vue';
  3. const SRC_DIR = path.resolve(__dirname, './src');
  4. const PUBLIC_DIR = path.resolve(__dirname, './public');
  5. const BUILD_DIR = path.resolve(__dirname, './www',);
  6. const filesNeedToExclude = ["./src/auto/robot/**"];
  7. import requireToUrlPlugin from './src/requireToUrlPlugin';
  8. export default async () => {
  9. return {
  10. plugins: [
  11. vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('swiper-') } } }),
  12. requireToUrlPlugin(),
  13. ],
  14. root: SRC_DIR,
  15. base: '',
  16. publicDir: PUBLIC_DIR,
  17. build: {
  18. outDir: BUILD_DIR,
  19. assetsInlineLimit: 0,
  20. emptyOutDir: true,
  21. rollupOptions: {
  22. treeshake: false,
  23. external: [
  24. ...filesNeedToExclude
  25. ]
  26. },
  27. },
  28. resolve: {
  29. alias: {
  30. '@': SRC_DIR,
  31. },
  32. },
  33. server: {
  34. host: true,
  35. },
  36. };
  37. }