-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
51 lines (50 loc) · 1.73 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
const path = require('path')
module.exports = {
output: {
// directory after bundling our code by webpack
path: path.join(__dirname, '/dist'),
// react js code will be inside our index.bundle.js
filename: 'index.bundle.js',
},
// for hot reloading
devServer: {
// port number to run dev server on
port: 3010,
// watch out for file changes
// watchContentBase: true
},
// now here we will declare how webpack will bundle our code intot a browser ready bundle
module: {
// rules to follow for handling different kind of files
// we can define rules for handling every kind of file like .js, .css, .scss, .svg etc
rules: [
{
//? match all files with extension .js or .jsx
test: /\.(js|jsx)$/,
// do not watch node_modules, as they are already compilled and ready to use
exclude: /node_modules/,
// when we match these file, what we would do?
// we would load them in the babael-loader
use: {
loader: 'babel-loader'
}
},
{
//? match all files with extension .css
test: /\.css$/,
use: [
// this will create a style tag in our index page, containing all the styles
'style-loader',
'css-loader'
]
},
{
//? match all files with these extensions for images
test: /\.(png|jpg|jpeg|svg)$/,
use: [
'file-loader'
]
}
]
}
}