const { defineConfig } = require(`@vue/cli-service`)
const UnoCSS = require(`@unocss/webpack`).default
const presetUno = require(`@unocss/preset-uno`).default
const presetIcons = require(`@unocss/preset-icons`).default
const transformerDirectives = require(`@unocss/transformer-directives`).default

module.exports = defineConfig({
  transpileDependencies: true,
  configureWebpack: {
    // 把原本需要写在webpack.config.js中的配置代码 写在这里 会自动合并
    externals: {
      jquery: `$`,
      echarts: `echarts`,
      axios: `axios`,
    },
    plugins: [
      UnoCSS({
        presets: [presetUno(), presetIcons()],
        transformers: [transformerDirectives()],
      }),
    ],
    optimization: {
      realContentHash: true,
    },
  },
  publicPath: process.env.NODE_ENV === `production` ? `/tryc/` : `/`,
  productionSourceMap: false,
  lintOnSave: false,
  devServer: {
    port: 8081,
    // proxy: {
    //   "/api": {
    //     target: "https://api.github.com",
    //     changeOrigin: true,
    //     ws: false,
    //     pathRewrite: {
    //       "^/api": ""
    //     }
    //   }
    // }
  },
})
