const path = require('path')

const resolve = dir => {
  return path.join(__dirname, dir)
}

const BASE_URL = process.env.NODE_ENV === 'production'
  ? './'
  : './'

module.exports = {
  publicPath: BASE_URL,
  // outputDir: 'mallFrontH5',
  outputDir: 'yimuFrontH5',
  lintOnSave: false,
  productionSourceMap: false,

  chainWebpack: config => {
    config.resolve.alias
      .set('@', resolve('src'))
      .set('_c', resolve('src/components'))


    config.module
      .rule('svg')
      .exclude.add(resolve('src/assets/icon'))
      .end();

    config.module
      .rule('svg-icon')
      .test(/\.svg$/)
      .include
      .add(resolve('src/assets/icon'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      }).end();
    config
      .plugin('html')
      .tap(args => {
        args[0].title = '一幕数字藏品'
        return args
      })
  },

  css: {
    loaderOptions: {
      less: {
        modifyVars: {
          hack: `true; @import "${resolve('src/assets/style/variables.less')}";`,
        },
      },
    },
  },

  devServer: {
    proxy: {
      '/root': {
        pathRewrite: {
          '^/root': '/'
        },
        // target: 'http://146.56.197.42:12009'
        // target: 'http://172.22.20.64:8100/root'
        // target: 'http://172.22.17.176:12008'
        // target: 'http://172.22.17.108:9089'
        // target: 'https://mall.inmvo.com/root'  
        target: 'https://testym.8n.cn/root'
      },
      '/chat': {
        pathRewrite: {
          '^/chat': ''
        },
        target: 'ws://172.22.20.64:8090',
        ws: true
      }
    }
  }
}
