-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
112 lines (109 loc) · 2.65 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
105
106
107
108
109
110
111
112
/* eslint-env node */
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const packageJson = require('./package.json');
const ignoreEnvs = Object.keys(process.env)
.filter((k) => k.startsWith('IGNORE_IDS_ON_'))
.reduce((ignores, k) => ({ ...ignores, [k]: process.env[k] }), {});
/** import('webpack').Configuration */
const config = {
entry: './src/main.tsx',
target: 'web',
output: {
filename: '[name]-[contenthash].js',
publicPath: '/',
chunkFilename: '[name]-[id].js',
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
transpileOnly: true,
compilerOptions: {
importsNotUsedAsValues: 'remove',
jsx: 'react-jsx',
},
},
},
{
test: /\.less$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
sourceMap: true,
modules: {
localIdentName: '[local]--[hash:base64:5]',
},
},
},
{
loader: 'less-loader',
},
],
},
{
test: /\.css/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'public/index.html'),
}),
new webpack.ProvidePlugin({
process: 'process/browser.js',
Buffer: ['buffer', 'Buffer'],
}),
new MiniCssExtractPlugin({
filename: '[name]-[hash].css',
}),
new webpack.EnvironmentPlugin({
INFURA_ID: process.env.INFURA_ID || 'd74bd8586b9e44449cef131d39ceeefb',
VERSION: `${packageJson.version}-${process.env.COMMIT ?? 'dev'}`,
...ignoreEnvs,
}),
],
devServer: {
host: '0.0.0.0',
contentBasePublicPath: '/',
contentBase: path.resolve(__dirname, 'public'),
hot: true,
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json'],
alias: {
'@': path.resolve(__dirname, 'src'),
},
fallback: {
os: 'os-browserify/browser',
https: 'https-browserify',
http: 'stream-http',
stream: 'stream-browserify',
util: 'util',
assert: false,
buffer: require.resolve('buffer'),
},
},
node: {
global: true,
__filename: false,
__dirname: false,
},
};
module.exports = config;