-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.js
111 lines (104 loc) · 2.5 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
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
console.log('Building with WebPack', process.env.NODE_ENV)
const isDevelopmentMode = process.env.NODE_ENV === 'development'
const htmlWebpackPlugin = new HtmlWebpackPlugin({
template: path.join(__dirname, 'src/index.html'),
filename: './index.html',
})
const copyWebpackPlugin = new CopyWebpackPlugin([
{
from: './_redirects',
to: './_redirects',
toType: 'file',
}
])
module.exports = {
entry: path.join(__dirname, 'src', 'index.jsx'),
output: {
filename: '[name].[hash].js',
path: path.join(__dirname, 'dist'),
publicPath: '/',
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
}
},
{
test: /\.scss$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
localIdentName: isDevelopmentMode ? '[path][name]__[local]--[hash:base64:5]' : '[hash:base64]',
importLoaders: 2,
},
},
'postcss-loader',
{
loader: 'resolve-url-loader',
options: {
sourceMap: true,
debug: true,
root: path.join(__dirname, 'src', 'images'),
}
},
{
loader: 'sass-loader',
options: {
includePaths: [
path.join(__dirname, 'src', 'styles'),
],
sourceMap: true,
sourceMapContents: false,
}
},
]
},
{
test: /\.css$/, // only used for external styles (toastify). see https://github.com/webpack/webpack/issues/8406
use: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 1,
},
},
'postcss-loader',
]
},
{
test: [/\.svg$/, /\.jpg$/, /\.png/],
use: 'file-loader',
},
]
},
plugins: [
htmlWebpackPlugin,
copyWebpackPlugin,
],
resolve: {
extensions: ['.js', '.jsx', '.json'],
modules: [
path.join(__dirname, 'src'),
'node_modules',
],
},
devServer: {
port: 3001,
historyApiFallback: {
index: '/index.html',
verbose: true,
disableDotRule: true
},
}
}