'use strict'
const titles = require('./title.js')
const glob = require('glob')
const pages = {}

glob.sync('./src/pages/**/app.js').forEach(path => {
  console.log(path)
  const chunk = path.split('./src/pages/')[1].split('/app.js')[0]
  pages[chunk] = {
    entry: path,
    template: 'public/index.html',
    title: titles[chunk],
    chunks: ['chunk-vendors', 'chunk-common', chunk]
  }
})
module.exports = {
  pages,
  baseUrl: './',
  // 生产环境是否生成 sourceMap 文件
  productionSourceMap: true,
  // devtool: 'source-map',
  chainWebpack: config => config.plugins.delete('named-chunks'),
  devServer: {
    proxy: {
      '/api': {
        // target: 'https://dp.huiju360.com.cn/hj_operations',
        target: 'http://192.168.0.62:8080', // wf
        // target: 'http://192.168.0.102:8080', // hyq
        // target: 'http://192.168.0.11', // ys
        // target: 'http://dev.ycjcjy.com', // frp
        changeOrigin: true, // 如果接口跨域，需要进行这个参数配置
        // pathRewrite: {
        //   '^/api': '/api-v2/api'
        // },
      },
    },
    // compress: true,
    disableHostCheck: true,   // That solved it
  }
}
