-
Notifications
You must be signed in to change notification settings - Fork 31
/
webpack.config.js
104 lines (103 loc) · 2.86 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const WorkboxPlugin = require('workbox-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const WebpackPwaManifest = require('webpack-pwa-manifest')
module.exports = env => ({
mode: !!env.production ? 'production' : 'development',
entry: './src/index.tsx',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].[contenthash].js',
},
devtool: !!env.production ? 'source-map' : 'eval-cheap-module-source-map',
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: 'ts-loader',
},
{
test: /(\.jpg|tesseract-core\.wasm\.js|worker\.min\.js|\.woff2|\.svg)$/i,
loader: 'file-loader',
options: {
name: 'lib/[name].[contenthash].[ext]',
},
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
],
},
resolve: {
extensions: ['.js', '.ts', '.tsx'],
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.html',
favicon: 'assets/favicon.svg',
}),
new CopyPlugin({
patterns: [
{
from: 'lib/cyber.traineddata.gz',
to: 'lib/cyber.traineddata.gz',
},
],
}),
new WebpackPwaManifest({
name: 'Optical Breacher Mk.1',
short_name: 'Optical Breacher',
description:
'Cyberpunk 2077 breach protocol minigame solver using camera + OCR',
background_color: '#fcee0a', // For splash screen
orientation: 'portrait',
display: 'standalone',
inject: true,
scope: '.',
theme_color: '#100606', // For title bar
start_url: './index.html',
publicPath: '.',
icons: [
{
src: path.resolve('assets/app-icon-maskable.png'),
sizes: [1024],
destination: 'lib',
purpose: 'maskable',
},
{
src: path.resolve('assets/app-icon.png'),
sizes: [96, 128, 192, 256, 384, 512, 1024],
ios: true,
destination: 'lib',
},
],
ios: {
'apple-mobile-web-app-title': 'Optical Breacher Mk.1',
'apple-mobile-web-app-status-bar-style': 'black-translucent',
'apple-mobile-web-app-capable': 'yes',
},
}),
new WorkboxPlugin.GenerateSW({
// these options encourage the ServiceWorkers to get in there fast
// and not allow any straggling "old" SWs to hang around
clientsClaim: true,
skipWaiting: true,
maximumFileSizeToCacheInBytes: 4096 * 1024,
additionalManifestEntries: [
{ url: 'index.html', revision: `${Date.now()}` },
],
}),
],
devServer: {
port: 1234,
historyApiFallback: true,
// host: 'localhost'
useLocalIp: true,
http2: true,
// Accessing camera requires HTTPS
https: true,
},
})