'use strict'
// Template version: 1.2.4
// see http://vuejs-templates.github.io/webpack for documentation.

const path = require('path')

const argv = require('yargs').argv

// 获取环境变量
const project = argv.define;

process.stdout.write('===attention=== 当前项目：' + project + '\n\n')

const devEnvConfig = require('./' + project + '/dev.env.js')
const prodEnvConfig = require('./' + project + '/prod.env.js')
module.exports = {
  dev: {

    // Paths
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {
      "/crm400": {
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'crm400'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/crm400': '/'
        }
      },
      "/walter": {
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'walter'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/walter': '/'
        }
      },
      "/club": {
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'club'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/club': '/'
        }
      },

      "/houserkeep": {
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'houserkeep'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/houserkeep': '/'
        }
      },
      "/activity": {
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'activity'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/activity': '/'
        }
      },
      "/article": {
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'article'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/article': '/'
        }
      },
      "/steward": {
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'steward'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/steward': '/'
        }
      },
      "/question": { //问卷接口
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'question'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/question': '/'
        }
      },
      "/charge": { //收费接口
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'charge'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/charge': '/'
        }
      },
      "/activiti": {
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'activiti'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/activiti': '/'
        },
      },
      "/decorationManage": {
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'decorationManage'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/decorationManage': '/'
        },
      },
      "/itemPassport": {
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'itemPassport'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/itemPassport': '/'
        },
      },
      "/itemHouse": {
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'itemHouse'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/itemHouse': '/'
        },
      },
      "/qpi": {
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'qpi'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/qpi': '/'
        },
      },
      "/datashow": { //深交所 - 管理视图
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'datashow'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/datashow': '/'
        }
      },
      "/warning": { //深交所 - 预警
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'warning'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/warning': '/'
        }
      },
      "/groupcontrol": { //深交所 - 会议管理
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'groupcontrol'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/groupcontrol': '/'
        }
      },
      "/energy-charging": { //深交所 - 水电气表查询
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'energyCharging'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/energy-charging': '/'
        }
      },
      "/wuyecrm": {
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'wuyecrm'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/wuyecrm': '/'
        }
      },
      "/gf": {
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'gf'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/gf': '/'
        }
      },
      "/filemanager": {
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'filemanager'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/filemanager': '/'
        }
      },
      "/leasing": { //审批
        // target:devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'leasing'),
        target: 'http://180.168.37.139/leasing',
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/leasing': '/'
        }
      },
      "/neikong": { //审批
        // target:devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'neikong'),
        target: 'http://180.168.37.139/neikong',
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/neikong': '/'
        }
      },
      "/activiti": { //审批
        target: 'http://180.168.37.139/activiti',
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/activiti': '/'
        }
      },
      "/landcrm": { //审批 上传附件
        target: 'http://180.168.37.139/landcrm',
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/landcrm': '/'
        }
      },
      "/device": {
        target: devEnvConfig.findAddr(JSON.parse(devEnvConfig.hostConfig), 'device'),
        secure: false,
        changeOrigin: true,
        pathRewrite: {
          '^/device': '/'
        }
      },

    },

    env: devEnvConfig,
    // Various Dev Server settings
    host: '172.18.0.110', // can be overwritten by process.env.HOST
    port: 8082, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
    autoOpenBrowser: false,
    errorOverlay: true,
    notifyOnErrors: true,
    poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-

    // Use Eslint Loader?
    // If true, your code will be linted during bundling and
    // linting errors and warnings will be shown in the console.
    useEslint: true,
    // If true, eslint errors and warnings will also be shown in the error overlay
    // in the browser.
    showEslintErrorsInOverlay: false,

    /**
     * Source Maps
     */

    // https://webpack.js.org/configuration/devtool/#development
    devtool: 'eval-source-map',

    // If you have problems debugging vue-files in devtools,
    // set this to false - it *may* help
    // https://vue-loader.vuejs.org/en/options.html#cachebusting
    cacheBusting: true,

    // CSS Sourcemaps off by default because relative paths are "buggy"
    // with this option, according to the CSS-Loader README
    // (https://github.com/webpack/css-loader#sourcemaps)
    // In our experience, they generally work as expected,
    // just be aware of this issue when enabling this option.
    cssSourceMap: false,
  },

  build: {
    env: prodEnvConfig,
    // Template for index.html
    index: path.resolve(__dirname, '../dist/index.html'),

    // Paths
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: './',

    /**
     * Source Maps
     */

    productionSourceMap: false,
    // https://webpack.js.org/configuration/devtool/#production
    // devtool: '#source-map',

    // Run the build command with an extra argument to
    // View the bundle analyzer report after build finishes:
    // `npm run build --report`
    // Set to `true` or `false` to always turn it on or off
    bundleAnalyzerReport: process.env.npm_config_report
  }
}
