-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.common.js
66 lines (61 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
const path = require('path');
const ROOT = process.cwd();
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const TsConfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const { version } = require(path.join(ROOT, '/package.json'));
module.exports = {
entry: path.join(ROOT, 'src/index.tsx'),
resolve: {
extensions: ['.ts', '.tsx', '.js'],
plugins: [new TsConfigPathsPlugin({ configFile: path.join(ROOT, 'tsconfig.json') })]
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
transpileOnly: true
}
},
{
test: /\.(svg|jpg|jpeg|png)$/i,
type: 'asset/resource',
generator: {
filename: 'assets/[name].[contenthash][ext]'
}
},
{
test: /\.(png)$/i,
type: 'asset/resource',
exclude: /assets/,
generator: {
filename: '[name].[contenthash][ext]'
}
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
generator: {
filename: 'fonts/[name][ext]'
}
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env.BRAND_APP_LOGO': JSON.stringify(process.env.BRAND_APP_LOGO || ''),
'process.env.APP_VERSION': JSON.stringify(process.env.APP_VERSION) || JSON.stringify(version),
'process.env.COLLECTOR_URL': JSON.stringify(process.env.COLLECTOR_URL || ''),
'process.env.MOCK_ITEM_COUNT': JSON.stringify(process.env.MOCK_ITEM_COUNT),
'process.env.MOCK_DELAY_RESPONSE': JSON.stringify(process.env.MOCK_DELAY_RESPONSE)
}),
new HtmlWebpackPlugin({
template: path.join(ROOT, '/public/index.html'),
templateParameters: {
title: process.env.BRAND_TITLE || 'Skupper console'
}
})
]
};