const path = require('path');
const PluginUglifyjs = require('@wepy/plugin-uglifyjs')

const DefinePlugin = require('@wepy/plugin-define');
let env = process.env.NODE_ENV.toString();
var prod = env.split('-')[0] === 'prod';
module.exports = {
  wpyExt: '.wpy',
  eslint: false,
  cliLogs: !prod,
  static: ['static'],
  build: {
  },
  resolve: {
    extensions: ['.js', '.wxs', '.wpy'],
    alias: {
      counter: path.join(__dirname, 'src/components/counter'),
      '@': path.join(__dirname, 'src'),
      // 根据在package.json中配置的不同编译命令，引用/config下不同的配置文件
      '@config': path.join(__dirname, 'src', 'config', 'index')
    },
    aliasFields: ['wepy', 'weapp'],
    modules: ['node_modules']
  },
  compilers: {
    less: {
      compress: true
    },
    babel: {
      sourceMap: true,
      presets: [
        '@babel/preset-env'
      ],
      plugins: [
        '@wepy/babel-plugin-import-regenerator'
      ]
    }
  },
  plugins: [
    PluginUglifyjs({
      compress: true
    }),
    DefinePlugin({
      NODE_ENV: JSON.stringify(env)
    })
  ],
  appConfig: {
    noPromiseAPI: ['createSelectorQuery']
  }
}
