// 配置手册： https://cli.vuejs.org/zh/config/#vue-config-js

const { defineConfig } = require("@vue/cli-service");
var package = require("./package.json");
var v = package.version;
const timestamp = Date.now();

let config = {
  transpileDependencies: true,
  // publicPath: './',
  devServer: {
    port: process.env.VUE_APP_DEV_PORT || 8056,
    proxy: {
      "/(api|fss)/": {
        target: process.env.VUE_APP_DEV_PROXY,
        changeOrigin: true,
      },
    },
    // https://webpack.js.org/configuration/dev-server/#overlay
    client: {
      overlay: false,
    },
  },
  productionSourceMap: false,
};

if (process.env.NODE_ENV === "production") {
  config.css = Object.assign(config.css || {}, {
    extract: {
      filename: `css/[name].${v}.${timestamp}.css`,
      chunkFilename: `css/[name].${v}.${timestamp}.css`,
    },
  });
  config.configureWebpack = Object.assign(config.configureWebpack || {}, {
    output: {
      filename: `js/[name].${v}.${timestamp}.js`,
      chunkFilename: `js/[name].${v}.${timestamp}.js`,
    },
  });
}

module.exports = defineConfig(config);
