This repository has been archived by the owner on Mar 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
90 lines (89 loc) · 2.67 KB
/
webpack.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
80
81
82
83
84
85
86
87
88
89
90
const path = require('path'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
MiniCssExtractPlugin = require('mini-css-extract-plugin'),
OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
module.exports = {
entry: {
panel: './src/panel.js',
mobile: './src/mobile.js',
video_overlay: './src/video_overlay.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
},
optimization: {
minimizer: [new OptimizeCSSAssetsPlugin({})],
splitChunks: {
cacheGroups: {
vendor: {
chunks: 'initial',
name: 'vendor',
test: 'vendor',
enforce: true,
},
},
},
},
plugins: [
new HtmlWebpackPlugin({
filename: 'panel.html',
template: 'src/assets/html/panel.html',
chunks: ['panel'],
}),
new HtmlWebpackPlugin({
filename: 'mobile.html',
template: 'src/assets/html/mobile.html',
chunks: ['mobile'],
}),
new HtmlWebpackPlugin({
filename: 'video_overlay.html',
template: 'src/assets/html/video_overlay.html',
chunks: ['video_overlay'],
}),
new MiniCssExtractPlugin(),
],
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
plugins: ['@babel/plugin-proposal-optional-chaining'],
},
},
},
{
test: /\.css$/,
use: [
// Creates `style` nodes from JS strings and extracts CSS into the output directory
MiniCssExtractPlugin.loader,
// Translates CSS into CommonJS
'css-loader',
],
},
{
test: /\.(png|jpe?g|gif|svg)$/i,
// Resolve images and emit into the assets directory
use: [
{
loader: 'file-loader',
options: {
esModule: false,
name: '[name].[ext]',
outputPath: 'assets',
},
},
],
},
],
},
resolve: {
alias: {
react: 'preact/compat',
'react-dom': 'preact/compat',
},
},
};