UNPKG

builder-we-app-cloud-account

Version:

The KOS Builder Module for Choice CloudAccount MicroApp

59 lines (49 loc) 1.92 kB
'use strict'; const path = require('path'); const webpack = require('webpack'); const get = require('lodash/get'); const CleanWebpackPlugin = require('clean-webpack-plugin'); const systemModulePlugin = require('@saasfe/saas-webpack-system-module'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const { ROOT_PATH, SAAS_CONFIG, ASSETS_URL, PUBLISH_ENV, CDN_BASE, DOMAIN_ENV } = require('../util/const'); const microAppName = get(SAAS_CONFIG, 'microAppName', ''); module.exports = function (config) { config.plugins = config.plugins || []; config.plugins.push(new systemModulePlugin()); config.plugins.push(new CleanWebpackPlugin([path.join(ROOT_PATH, 'build')], { root: ROOT_PATH, })); config.plugins.push(new webpack.DefinePlugin({ 'MICRO_APPNAME': JSON.stringify(microAppName), 'PUBLIC_PATH': JSON.stringify(ASSETS_URL), 'PUBLISH_ENV': JSON.stringify(PUBLISH_ENV), 'ENV': JSON.stringify(DOMAIN_ENV), 'CDN_BASE': JSON.stringify(CDN_BASE), })); config.plugins.push(new MiniCssExtractPlugin({ filename: '[name].css', chunkFilename: '[name].css', })); // 只打包moment/locale里的中文本地化内容 config.plugins.push(new webpack.ContextReplacementPlugin( /moment[/\\]locale$/, /zh-cn/, )); // 云平台特殊入口配置 config.plugins.push(new HtmlWebpackPlugin({ filename: 'home/index.html', template: require.resolve(path.join(ROOT_PATH, 'public/home/index.ejs')), inject: false, // todo: 确认下publicPath是否可以删除 publicPath: `${ASSETS_URL}home/`, favicon: require.resolve(path.join(ROOT_PATH, 'src/images/logo.png')), })) // roadhog升级webpack4配置 config.plugins.push(new CopyWebpackPlugin([{ from: path.join(ROOT_PATH, 'public'), }])) };