-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.app.js
37 lines (33 loc) · 1.16 KB
/
webpack.config.app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const path = require('path');
const { merge } = require('webpack-merge');
const commonConfig = require('./webpack.config.common');
const createHtml = require("./config/create-html");
const getEntry = require("./config/get-entry");
const getPagePath = require("./config/get-page-path");
const defaultEntry = getEntry("./src/pages");
const defaultHtmlArr = createHtml(getPagePath("./src/pages"))
const getEntryFromApps = (apps)=>{
return apps.reduce((res,app)=>{
res[`${app}/${app}`] = `./src/pages/${app}/index.js`
return res
},{})
}
module.exports = (env, argv) => {
const { apps="" } = env
const appsArr = apps.split(",");
const entry = apps ? getEntryFromApps(appsArr): defaultEntry;
const htmlArr = apps ? createHtml(appsArr): defaultHtmlArr;
apps && console.log(`Webpack Build Apps: ${apps}`)
return merge(commonConfig(env, argv), {
entry,
devtool: 'inline-source-map',
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, './build'),
library: 'app',
libraryTarget: 'umd',
umdNamedDefine: true
},
plugins: [...htmlArr]
})
}