forked from EpicGames/PixelStreamingInfrastructure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
75 lines (70 loc) · 1.83 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
// Copyright Epic Games, Inc. All Rights Reserved.
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const fs = require('fs');
const pages = fs.readdirSync('./src', { withFileTypes: true })
.filter(item => !item.isDirectory())
.filter(item => path.parse(item.name).ext === '.html')
.map(htmlFile => path.parse(htmlFile.name).name);
module.exports = {
entry: pages.reduce((config, page) => {
config[page] = `./src/${page}.ts`;
return config;
}, {}),
plugins: [].concat(pages.map((page) => new HtmlWebpackPlugin({
title: `${page}`,
template: `./src/${page}.html`,
filename: `${page}.html`,
chunks: [page],
}), )),
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: [
/node_modules/,
],
},
{
test: /\.html$/i,
use: 'html-loader'
},
{
test: /\.css$/,
type: 'asset/resource',
generator: {
filename: 'css/[name][ext]'
}
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource',
generator: {
filename: 'images/[name][ext]'
}
}
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.svg', '.json'],
},
output: {
filename: '[name].js',
library: 'epicgames-frontend',
libraryTarget: 'umd',
path: path.resolve(__dirname, '../../../SignallingWebServer/Public'),
clean: true,
globalObject: 'this',
hashFunction: 'xxhash64',
},
experiments: {
futureDefaults: true
},
devServer: {
static: {
directory: path.join(__dirname, '../../../SignallingWebServer/Public'),
},
},
}