/**
 * webpack 打包配置文件
 * @author ilex
 */
const MFConfig = require('amos-build/lib/MFConfig');
const { getReactMf, getRCConfigInfo } = require('amos-build/lib/tools/pluginConfig');
const resolveCwd = require('amos-build/lib/tools/resolveCwd');
const deps = require('./package.json').dependencies;

const umdRc = getRCConfigInfo('umd', '.');

// ------------------------------------
// 入口点
// ------------------------------------
const entry = {
  app: './mf/entry.js'
};

const mfOption = {
  name: 'amosiot',
  library: { type: 'var', name: 'amosiot' },
  filename: 'remoteEntry.js',
  exposes: {
    './access': './mf/index.js'
  },
  shared: {
    ...getReactMf(deps.react, deps['react-dom'])
  }
};

const config = {
  tpl: './tpl.html',
  toFile: 'index.html',
  port: 3919,
  entry,
  outputPath: resolveCwd('amosiot_dist'),
  mfConfig: mfOption,
  lint: false,
  sourceMap: false
};

const defaultConfig = MFConfig(config);

defaultConfig.name = 'amos-iot-access';

// 由于 iot remote 存放的路径不确定，此处禁止重新赋值
// defaultConfig.output.publicPath = '';

// 设置 外部脚本配置
defaultConfig.externals = umdRc.externals;

module.exports = defaultConfig;
