vite.config.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import path from "path";
  2. import { defineConfig, loadConfigFromFile, loadEnv, mergeConfig } from "vite";
  3. import vue from "@vitejs/plugin-vue2";
  4. import WindiCSS from "vite-plugin-windicss";
  5. import AutoImport from "unplugin-auto-import/vite";
  6. const config = defineConfig(async ({ command, mode, ssrBuild }) => {
  7. const subConfigModule = await loadConfigFromFile({ command, mode, ssrBuild }, path.join(process.cwd(), `./vite.config.${mode}.ts`))
  8. const baseConfig = {
  9. resolve: {
  10. alias: { "@pc": path.join(process.cwd(), './src/pc'), "@h5": path.join(process.cwd(), './src/h5') }
  11. },
  12. build: {
  13. minify: true,
  14. rollupOptions: {
  15. input: {
  16. pc: path.join(process.cwd(), 'index.html'),
  17. h5: path.join(__dirname, 'index_h5.html')
  18. }
  19. }
  20. },
  21. plugins: [
  22. vue(),
  23. WindiCSS(),
  24. AutoImport({
  25. imports: ["@vueuse/core"],
  26. dts: "src/auto-imports.d.ts",
  27. }),
  28. ],
  29. server: {
  30. port: 3333,
  31. },
  32. }
  33. return mergeConfig(baseConfig, subConfigModule?.config as any, false)
  34. });
  35. export default config;