vite.config.ts 795 B

12345678910111213141516171819202122232425262728293031323334
  1. import { defineConfig } from "vite";
  2. import vue from "@vitejs/plugin-vue";
  3. import { resolve } from "path";
  4. let app = "liantong";
  5. if (process.argv.length > 3) {
  6. app = process.argv[process.argv.length - 1].trim();
  7. }
  8. // https://vitejs.dev/config/
  9. export default defineConfig({
  10. build: {
  11. lib: {
  12. entry: resolve(__dirname, `src/app/${app}/index.ts`),
  13. name: app,
  14. // the proper extensions will be added
  15. fileName: app,
  16. },
  17. rollupOptions: {
  18. // 确保外部化处理那些你不想打包进库的依赖
  19. external: ["vue"],
  20. output: {
  21. // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
  22. globals: {
  23. vue: "Vue",
  24. },
  25. },
  26. },
  27. },
  28. plugins: [vue()],
  29. server: {
  30. port: 9005,
  31. },
  32. });