const path = require('path');

const params = {
  context: path.resolve(__dirname, '../../'),
  mode: 'development',
  watch: true,
  entry: path.resolve(__dirname, '../src/index.ts'),
  output: {
    path: path.resolve(__dirname, '../lib'),
    filename: '[name].bundle.js',
    chunkFilename: '[name].chunk.js',
    publicPath: '/',
    pathinfo: false,
    library: 'weda-render',
    libraryTarget: 'umd',
    globalObject: 'this',
  },
  externals: {
    react: { root: 'React', commonjs: 'react', commonjs2: 'react' },
    'react-dom': {
      root: 'ReactDOM',
      commonjs: 'react-dom',
      commonjs2: 'react-dom',
    },
    mobx: { root: 'mobx', commonjs: 'mobx', commonjs2: 'mobx' },
    '@cloudbase/js-sdk': {
      root: 'cloudbase',
      commonjs: '@cloudbase/js-sdk',
      commonjs2: '@cloudbase/js-sdk',
    },
    '@cloudbase/weda-cloud-sdk': {
      root: 'CloudSDK',
      commonjs: '@cloudbase/weda-cloud-sdk',
      commonjs2: '@cloudbase/weda-cloud-sdk',
    },
    '@zxing/library': {
      root: 'ZXing',
      commonjs: '@zxing/library',
      commonjs2: '@zxing/library',
    },
    '@babel/standalone': {
      root: 'Babel',
      commonjs: '@babel/standalone',
      commonjs2: '@babel/standalone',
    },
  },
  definePlugin: {
    'process.env.buildType': '"web"',
    'process.env.isApp': false,
    'process.env.isAdminPortal': false,
    'process.env.historyType': '"HASH"',
  },
};

module.exports = require('./web.prod.js')(params);
