-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
97 lines (93 loc) · 1.81 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
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
const isDevelopment = process.env.NODE_ENV !== 'production'
const path = require('path')
module.exports = {
mode: isDevelopment ? 'development' : 'production',
resolve: {
fallback: {
path: 'path-browserify',
buffer: 'buffer',
},
},
module: {
rules: [
{
test: /node_modules\/vfile\/core\.js/,
use: [
{
loader: 'imports-loader',
options: {
type: 'commonjs',
imports: ['single process/browser process'],
},
},
],
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.ya?ml$/,
type: 'json', // Required by Webpack v4
use: 'yaml-loader',
},
{
test: /\.md$/i,
use: 'raw-loader',
},
{
test: /\.(png|jpe?g|gif|svg)$/i,
use: [
{
loader: 'file-loader',
},
],
},
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: require.resolve('babel-loader'),
options: {
presets: [
'@babel/preset-env',
[
'@babel/preset-react',
{
runtime: 'automatic',
},
],
],
plugins: [
'babel-plugin-styled-components',
isDevelopment && require.resolve('react-refresh/babel'),
].filter(Boolean),
},
},
],
},
],
},
entry: {
javascript: './source/index.js',
},
output: {
filename: 'index.js',
path: __dirname + '/dist',
},
devServer: {
historyApiFallback: true,
contentBase: path.join(__dirname, 'dist'),
hot: true,
},
plugins: [
isDevelopment && new ReactRefreshWebpackPlugin(),
new HtmlWebpackPlugin({
title: 'Vélolibre',
template: 'index.html',
}),
].filter(Boolean),
}