const ENV = process.env.NODE_ENV
const BUILD_ENV = process.env.BUILD_ENV
const path = require('path')

const gameUrl = 'k3.eosget.io'

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

function getBaseUrl () {
  if (ENV === 'development') {
    return '/'
  } else if (BUILD_ENV === 'test') {
    return '/dist/'
  } else {
    let pre = BUILD_ENV === 'production' ? '' : `${BUILD_ENV}-`
    return `https://static.meechat.me/cdn/${pre}${gameUrl}/dist/`
  }
};

module.exports = {
  indexPath: ENV === 'production' ? '../protected/views/index.html' : 'index.html',
  outputDir: './dist', // build 时生成的生产环境构建文件的目录
  publicPath: getBaseUrl(),
  lintOnSave: true, // 关闭eslint
  productionSourceMap: false, // 生产环境取消source map
  pages: {
    index: {
      entry: '_src/main.js'
    }
  },
  chainWebpack: (config) => {
    config.resolve.alias
      .set('@', resolve('_src'))
      .set('!', resolve(''))
  },
  css: {
    loaderOptions: {
      sass: {
        data: `@import "@/style/mixins.scss";`
      }
    }
  }
}
