-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
74 lines (72 loc) · 1.66 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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const APP_DIR = path.resolve(__dirname, 'src');
const BUILD_DIR = path.resolve(__dirname, 'build');
const env = process.env.NODE_ENV || 'development';
module.exports = {
entry: ['@babel/polyfill', `${APP_DIR}/index.js`],
output: {
path: BUILD_DIR,
filename: `bundle.js`,
publicPath: `/${process.env.REACT_APP_HASH}/`,
},
mode: env,
devtool: env === 'development' ? 'source-map' : null,
resolve: {
extensions: ['.js', '.jsx'],
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: '/node_modules/',
},
{
test: /\.jsx$/,
loader: 'babel-loader',
exclude: '/node_modules/',
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(png|jpe?g|gif)$/,
loader: `url-loader?limit=10000&name=img/[name].[ext]`,
},
{
test: /\.svg$/,
use: [
{
loader: 'svg-url-loader',
options: {
limit: 10000,
},
},
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: `${APP_DIR}/index.html`,
filename: 'index.html',
inject: 'body',
}),
new webpack.DefinePlugin({
'process.env.REACT_APP_HASH': JSON.stringify(process.env.REACT_APP_HASH),
}),
],
devServer: {
contentBase: BUILD_DIR,
compress: true,
port: 5000,
historyApiFallback: true,
disableHostCheck: true,
},
watchOptions: {
ignored: /node_modules/
},
};