forked from TalkControl/talk-control
-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.common.js
79 lines (77 loc) · 2.42 KB
/
webpack.config.common.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const layouts = [
{
folder: 'on-stage',
filename: 'on-stage.html'
},
{
folder: 'presenter',
filename: 'presenter.html'
},
{
folder: 'presenter',
filename: 'presenter-mobile.html'
}
];
module.exports = {
entry: {
'tc-component': './src/client/tc-component/index.js',
'tc-controller': './src/client/tc-controller/index.js',
'on-stage': './src/client/layouts/on-stage/index.js',
presenter: './src/client/layouts/presenter/index.js'
},
module: {
rules: [
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader']
},
{
test: /\.(png|jpg|gif|eot|svg|woff|woff2|ttf)$/i,
use: [
{
loader: 'url-loader',
options: {
name: '[name].[ext]',
outputPath: 'assets',
limit: 1024
}
}
]
}
]
},
target: 'web',
output: {
publicPath: '', // Required by MiniCssExtractPlugin, but can be overridden dynamically (see tc-component/index.js)
filename: '[name].bundle.js'
},
resolve: {
alias: {
'@event-bus': path.resolve(__dirname, './src/common/event-bus/'),
'@services': path.resolve(__dirname, './src/common/services/'),
'@client': path.resolve(__dirname, './src/client/'),
'@plugins': path.resolve(__dirname, './src/plugins/'),
'@config': path.resolve(__dirname, './config/')
},
extensions: ['.js', '.json']
},
plugins: [
new MiniCssExtractPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/client/tc-controller/index.html',
chunks: ['tc-controller']
}),
...layouts.map(
layout =>
new HtmlWebpackPlugin({
filename: `${layout.filename}`,
template: `./src/client/layouts/${layout.folder}/${layout.filename}`,
chunks: [layout.folder]
})
)
]
};