-
Notifications
You must be signed in to change notification settings - Fork 16
/
webpack.config.js
55 lines (48 loc) · 1.43 KB
/
webpack.config.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const HtmlWebpackPlugin = require('html-webpack-plugin')
const webpackBaseDev = require('./webpackBase.dev.config')
const webpackBaseProd = require('./webpackBase.prod.config')
const getBase = env => (env === 'production' ? webpackBaseProd : webpackBaseDev)
const interfaceConfig = {
name: 'Interface',
entry: ['bootstrap-loader', 'index.js'],
output: {
publicPath: '/',
path: `${__dirname}/dist/interface`,
filename: '[name]_[hash].js',
},
plugins: [
new HtmlWebpackPlugin({
template: `${__dirname}/src/html/index.html`,
}),
],
}
const embeddedConfig = {
name: 'Embedded_Market',
entry: 'embedded/index.js',
output: {
publicPath: '',
path: `${__dirname}/dist/embedded`,
filename: '[name]_[hash].js',
},
plugins: [
new HtmlWebpackPlugin({
template: `${__dirname}/src/embedded/html/index.html`,
}),
],
}
const getConfig = project => (project === 'embedded' ? embeddedConfig : interfaceConfig)
module.exports = (env = {}) => {
if (!process.env.PROJECT) {
// eslint-disable-next-line
console.log(
'Please specify PROJECT environment variable, it should be one of: "interface", "embedded". By default the interface will be built',
)
}
const baseConfig = getBase(process.env.NODE_ENV)(env)
const projectConfig = getConfig(process.env.PROJECT)
return {
...baseConfig,
...projectConfig,
plugins: [...baseConfig.plugins, ...projectConfig.plugins],
}
}