forked from LeonGiering/gp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·77 lines (75 loc) · 1.97 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* Copyright © 2021 LMU Munich Medieninformatik. All rights reserved.
* Created by Changkun Ou <https://changkun.de>.
*
* Use of this source code is governed by a GNU GPLv3 license that
* can be found in the LICENSE file.
*/
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebpackObfuscator = require('webpack-obfuscator');
module.exports = env => {
const dist = env && env.production;
const config = {
mode: dist ? 'production' : 'development',
devServer: {
host: 'localhost',
open: true,
},
watch: true,
entry: './src/main.ts',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
{
test: /\.(glsl|vs|fs|vert|frag)$/,
use: ['raw-loader'],
},
],
},
resolve: {
fallback: {
crypto: require.resolve('crypto-browserify'),
buffer: require.resolve('buffer/'),
stream: require.resolve('stream-browserify'),
path: require.resolve('path-browserify'),
fs: false,
},
extensions: ['.tsx', '.ts', '.js'],
},
plugins: [
new CopyWebpackPlugin({
patterns: [{from: './assets', to: 'assets'}],
}),
new HtmlWebpackPlugin({
title: 'LMU Munich Computer Graphics SS21',
meta: {
viewport: `width=device-width, initial-scale=1,
shrink-to-fit=no, maximum-scale=1.0, user-scalable=no`,
},
}),
...(dist
? [
new WebpackObfuscator(
{
rotateStringArray: true,
},
['[name].js']
),
]
: []),
],
devtool: dist ? false : 'inline-source-map',
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'build'),
},
performance: {hints: false},
};
return config;
};