-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
57 lines (54 loc) · 1.4 KB
/
Copy pathwebpack.config.js
File metadata and controls
57 lines (54 loc) · 1.4 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
// helpful:
// https://www.robinwieruch.de/minimal-react-webpack-babel-setup/
// https://www.valentinog.com/blog/webpack/
// https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html
const path = require('path');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const isDevelopment = process.env.NODE_ENV !== 'production';
module.exports = {
entry: './index.js',
mode: isDevelopment ? 'development' : 'production',
devServer: {
hot: true,
static: {
directory: path.join(__dirname , '')
},
port: 3000,
},
module: {
rules: [
{
test: /\.(js)$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', { targets: 'defaults' }]
],
plugins: [isDevelopment && 'react-refresh/babel'].filter(Boolean),
},
},
],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
}
],
},
plugins: [
isDevelopment && new ReactRefreshWebpackPlugin(),
].filter(Boolean),
resolve: {
extensions: ['.webpack.js', '.web.js', '.js']
},
output: {
path: __dirname + '/dist',
publicPath: '/dist',
filename: 'bundle.js'
},
// Enable sourcemaps for debugging webpack's output.
devtool: 'source-map',
};