const { defineConfig } = require("@vue/cli-service");
const FileManagerPlugin = require("filemanager-webpack-plugin"); // 压缩文件夹
const isDev = process.env.NODE_ENV === "development";
let plugins = [];
// 避免打本地启项目时自动打zip包
if (!isDev) {
  plugins.push(
    new FileManagerPlugin({
      events: {
        onEnd: {
          // mkdir: ["./dist"],
          delete: ["./门户系统.zip", "./zip/"],
          copy: [{ source: "./dist", destination: "./zip/dist" }],
          archive: [{ source: "./zip", destination: "./zip/门户系统.zip" }],
        },
      },
    })
  );
}
module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false,
  // 打包目录
  outputDir: "dist",
  configureWebpack: {
    plugins: [...plugins],
  },
  devServer: {
    proxy: {
      "/api": {
        target: process.env.VUE_APP_API_BASE_URL,
        changeOrigin: true,
        pathRewrite: {
          "^/api": "",
        },
      },
    },
  },

  publicPath: "./",
});