-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ts
74 lines (70 loc) · 1.79 KB
/
webpack.config.ts
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
import { webpack, EnvironmentPlugin } from "webpack";
var path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebpackPwaManifest = require('webpack-pwa-manifest')
const CopyPlugin = require("copy-webpack-plugin");
const child_process = require('child_process');
const git = (command) => (
child_process.execSync(`git ${command}`, { encoding: 'utf8' }).trim()
)
module.exports = env => {
return {
entry: [
'./src/index'
],
output: {
path: path.join(__dirname, 'dist', env.TARGET_ENV || 'dev'),
publicPath: '/',
filename: 'bundle.js',
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
module: {
rules: [
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
},
},
{
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
'sass-loader'
]
},
{
test: /\.(ttf)$/,
use: {
loader: 'url-loader',
},
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource',
},
]
},
plugins: [
new HtmlWebpackPlugin({ template: './src/index.html' }),
new CopyPlugin({
patterns: [
{ from: "src/assets/icons/favicon.ico" },
],
}),
new WebpackPwaManifest({
name: 'subReddit TV',
icons: [
{ src: path.resolve('src/assets/icons/icon-192.png'), size: '192x192' },
{ src: path.resolve('src/assets/icons/icon-512.png'), size: '512x512' }
]
}),
new EnvironmentPlugin(['TARGET_ENV']),
new EnvironmentPlugin({'VERSION': git('describe --always')})
]
}
};