This repository was archived by the owner on Feb 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebpack.config.js
More file actions
86 lines (83 loc) · 2.09 KB
/
webpack.config.js
File metadata and controls
86 lines (83 loc) · 2.09 KB
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
/*eslint-env node*/
const { readdirSync, existsSync } = require('fs');
const { resolve, join } = require('path');
const { ProvidePlugin } = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const absolute = (path) => resolve(__dirname, path);
const packageRoot = '../nexus-desktop/packages';
const packages = existsSync(absolute(packageRoot))
? readdirSync(absolute(packageRoot))
: [];
module.exports = {
entry: absolute('./src/index.js'),
module: {
rules: [
{
test: /\.js$/,
include: [
absolute('src'),
...packages.map((path) => absolute(join(packageRoot, path, 'src'))),
],
use: {
loader: 'babel-loader',
},
},
{
test: /\.css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
],
},
{
test: /\.woff|.ttf|.eot|.svg$/,
type: 'asset',
},
],
},
resolve: {
extensions: ['.js'],
fallback: {
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
util: require.resolve('util'),
},
},
output: {
path: absolute('./dist'),
filename: 'bundle.js',
publicPath: '/',
},
devtool: 'inline-source-map',
devServer: {
static: {
publicPath: absolute('public'),
},
devMiddleware: {
stats: 'minimal',
},
port: process.env.PORT || 3000,
historyApiFallback: true,
allowedHosts: ['.localhost'],
},
plugins: [
new ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process',
}),
new ReactRefreshWebpackPlugin(),
new HtmlWebpackPlugin({
filename: './index.html',
template: './public/index.html',
}),
],
// Required to get hot reload working,
// see: https://github.com/webpack/webpack-dev-server/issues/2758
target: process.env.NODE_ENV === 'development' ? 'web' : 'browserslist',
};