const { defineConfig } = require('@vue/cli-service');
let name = require('./package.json')
module.exports = defineConfig({
  transpileDependencies: true,
  css: {
    loaderOptions: {
      // 向 CSS 相关的 loader 传递选项
      less: {
        javascriptEnabled: true,
      },
    },
  },
  devServer: {
    port: '9099',
    proxy: {
      // '/api': {
      //   target: 'http://localhost/:8000', // 代理目标的基础路径
      //   changeOrigin: true, // 更改请求头中的origin为目标URL
      //   rewrite: (path) => path.replace(/^\/api/, ''), // 重写请求路径，将/api替换为空字符串
      // }
      '/api/(latex|puml|graphviz|flowchart|mermaid)': {
        target: 'https://g.aomao.com/',
        changeOrigin: true,
        pathRewrite: { '^/api': '' },
      },
      [process.env.VUE_APP_BASE_URL]: {
        // target: 'https://editor.aomao.com',
        target: 'http://127.0.0.1:3000',
        changeOrigin: true,
        pathRewrite: { ['^' + process.env.VUE_APP_BASE_URL]: '' },
      },
    },
    headers: {
      'Access-Control-Allow-Origin': '*' // 主应用获取子应用时跨域响应头
    }
  },
  configureWebpack: {
    output: {
      library: `${name}-[name]`,
      libraryTarget: 'umd', // 把微应用打包成 umd 库格式


      // libraryTarget: "system",
    },
  },
});
