// const { defineConfig } = require('@vue/cli-service')
// module.exports = defineConfig({
//   transpileDependencies: true
// })

const path = require('path')

function resolve(dir) {
  return path.join(__dirname, dir)
}
const port = process.env.port || process.env.npm_config_port || 8081 // dev port
module.exports = {
  publicPath: '/',
  parallel: false,
  outputDir: 'lib',
  assetsDir: 'static',
  lintOnSave: process.env.NODE_ENV === 'development',
  productionSourceMap: false,
  devServer: {
    host: '127.0.0.1',
    port: port,
    overlay: {
      warnings: false,
      errors: true
    },
    proxy : {
      "/web/UploadBase64String" : {
        "target" : "https://ss.szande.com",
        "changeOrigin" : true,
        "pathRewrite" : {
          "^/web/UploadBase64String" : "/UploadBase64String"
        }
      },
      "/web/Upload" : {
        "target" : "https://ss.szande.com",
        "changeOrigin" : true,
        "pathRewrite" : {
          "^/web/Upload" : "/Upload"
        }
      },
      "/web/send" : {
        "target" : "https://wst.ecrp.cn",
        // "target" : "https://ts.ecrp.cn",
        "changeOrigin" : true,
        "pathRewrite" : {
          "^/web/send" : "/send"
        }
      },
      "/web" : {
        "target" : "https://wx.szande.com",
        // "target" : "https://ts.ecrp.cn",
        "changeOrigin" : true,
        "pathRewrite" : {
          "^/web" : "/"
        }
      }
    }
  },
  configureWebpack: {
    // provide the app's title in webpack's name field, so that
    // it can be accessed in index.html to inject the correct title.
    resolve: {
      alias: {
        '@': resolve('src')
      }
    },
    module: {
      rules: [
        // 配置读取 *.md 文件的规则
        {
          test: /\.md$/,
          use: [
            { loader: "html-loader" },
            { loader: "markdown-loader", options: {} }
          ]
        }
      ]
    }
  },
  chainWebpack(config) {
    // when there are many pages, it will cause too many meaningless requests
    config.plugins.delete('prefetch')
    config.module
        .rule('svg')
        .exclude.add(resolve('src/icons'))
        .end()
    config.module
        .rule('icons')
        .test(/\.svg$/)
        .include.add(resolve('src/icons'))
        .end()
        .use('svg-sprite-loader')
        .loader('svg-sprite-loader')
        .options({
          symbolId: 'icon-[name]'
        })
        .end()
  }
}
