const path = require('path');
var systemConfig = require('./public/systemConf.js');

function resolve(dir) {
  return path.join(__dirname, '..', dir);
}

module.exports = {
  devServer: {
    port: 8081,
    proxy: {
      '/baseService': {
        // 此处的写法,目的是为了 将 /2dapi/jsonz 替换target的值
        // target: 'http://apmstandard/',
        target: 'http://develop.ysbdtp.com',
        // 允许跨域
        changeOrigin: true,
        ws: true,
        pathRewrite: {
          '^/baseService': ''
        }
      },
      '/sysGraphService': {
        // 此处的写法,目的是为了 将 /2dapi/jsonz 替换target的值
        // target: 'http://127.0.0.1:8833',
        target: 'http://develop.ysbdtp.com/adm-diagram',
        // 允许跨域
        changeOrigin: true,
        pathRewrite: {
          '^/sysGraphService': ''
        }
      },
      '/loginRequest': {
        // 此处的写法,目的是为了 将 /2dapi/jsonz 替换target的值
        // target: 'http://apmstandard/',
        target: 'http://develop.ysbdtp.com/adm-server',
        // 允许跨域
        changeOrigin: true,
        ws: true,
        pathRewrite: {
          '^/loginRequest': ''
        }
      },
      '/middleService': {
        // 此处的写法,目的是为了 将 /2dapi/jsonz 替换target的值
        // target: 'http://apmstandard/',
        target: 'http://develop.ysbdtp.com/adm-middleware',
        // 允许跨域
        changeOrigin: true,
        ws: true,
        pathRewrite: {
          '^/middleService': ''
        }
      },
    }
  },
  pages: {
    index: {
      entry: 'src/main.js',
      template: 'public/index.html',
      filename: 'index.html'
    }
  },
  publicPath: '/' + systemConfig.baseRouteUrl,
  //当运行vue-cli-service build时生成的生产环境构建环境的目录。用法和webpack的output.path一样,不要修改output.path
  outputDir: systemConfig.baseRouteUrl,
  //放置打包后生成的静态资源(js、css、img、fonts)的目录,该目录相对于outputDir。
  assetsDir: 'public',
  //指定生成的index.html的输出路径,相对于outputDir。也可以是一个绝对路径。
  indexPath: 'index.html',
  // chainWebpack: config => {
  //   config.module
  //     .rule('js')
  //     .include
  //     .add(resolve('packages'))
  //     .end()
  //     .use('babel')
  //     .loader('babel-loader')
  //     .tap(options => { return options })
  //     .end();
  //   const svgRule = config.module.rule('svg');
  //   svgRule.uses.clear();
  //   svgRule
  //   // .test(/\.svg$/)
  //   .include
  //   .add(path.resolve(__dirname,"packages/static/svg"))
  //   .end()
  //     .use('vue-loader')
  //     .loader('vue-loader')
  //     .end()
  //     .use('vuecomponent-svg-loader')
  //     .loader('vuecomponent-svg-loader')
  //     .end();
  // },
  configureWebpack: {
    devtool: '#source-map',
    resolve: {
      alias: {
        'vue$': 'vue/dist/vue.esm.js',
        'jQuery': 'jquery/dist/jquery.min'
      }
    }
  }
};