vite.config.js


import legacy from "@vitejs/plugin-legacy";
const plugins = [
  vue(),
  legacy({
    targets: [
      "> 1%, last 1 version, ie >= 11",
      "safari >= 10",
      "Android > 39",
      "Chrome >= 60",
      "Safari >= 10.1",
      "iOS >= 10.3",
      "Firefox >= 54",
      "Edge >= 15"
    ],
    additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
    polyfills: ["es.promise.finally", "es/map", "es/set"],
    modernPolyfills: ["es.promise.finally"]
  })
];

export default defineConfig({
  server: {
    fs: {
      strict: false
    }
  },
  plugins,
  resolve: {
    alias: {
      "@": resolve("./src")
    }
  },
  build: {
    outDir: 'dist',
    target: ['es2015'], // 这一段必填
    rollupOptions: {
      external:['axios'],
      input: pageEntry,
      output: {
        manualChunks(id) {
          if (id.includes("node_modules")) {
            return id
              .toString()
              .split("node_modules/")[1]
              .split("/")[0]
              .toString();
          }
        }
      }
    }
  }
});

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐