const path = require('path');

const params = {
  context: path.resolve(__dirname, '../../'),
  mode: 'production',
  watch: false,
  entry: path.resolve(__dirname, '../src/index.ts'),
  output: {
    path: path.resolve(__dirname, '../lib'),
    filename: '[name].[contenthash].bundle.js',
    chunkFilename: '[name].[contenthash].chunk.js',
    /**
     * 和cdn发布地址强绑定
     * 以兼容 qiankun 加载，没有 currentScript 的问题
     * 私有化场景下需要专门打包处理
     */
    publicPath: 'https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/',
    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',
    },
    acorn: {
      root: 'acorn',
      commonjs: 'acorn',
      commonjs2: 'acorn',
    },
  },
  definePlugin: {},
};

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