/*
    rollup 配置文件
*/
import createModuleConfig from './config/rollupRenderModuleConfig';
import createStyleConfig from './config/rollupRenderStyleConfig';
import moduleMap from './config/obtainComponentsName';

const isDev = process.env.NODE_ENV === 'development';



/*
    dev 情况下不做样式抽离
    其他环境下，除了基本的 js 打包外，遍历要拆分的模块，分别生成一个配置项，在这个配置项中处理各自的样式分离
*/
const rollupConfig = isDev
  ? createModuleConfig({ ...moduleMap.cModuleMap, ...moduleMap.tcModuleMap, ...moduleMap.bcModuleMap }, isDev)
  : [createModuleConfig({ ...moduleMap.cModuleMap, ...moduleMap.tcModuleMap, ...moduleMap.bcModuleMap }, isDev)].concat(
      Object.keys(moduleMap.cModuleMap).map(moduleName => createStyleConfig(moduleName, 'components')),
      Object.keys(moduleMap.tcModuleMap).map(moduleName => createStyleConfig(moduleName, 'themeComponents')),
      Object.keys(moduleMap.bcModuleMap).map(moduleName => createStyleConfig(moduleName, 'businessComponents'))
    );

export default rollupConfig;
// export default Object.keys(moduleMap.bcModuleMap).map(moduleName => createStyleConfig(moduleName, 'businessComponents'))
