-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
79 lines (76 loc) · 1.87 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
const path = require("path");
module.exports = {
entry: path.join(__dirname,"/src/index.js"),
output: {
path: path.join(__dirname,"/build"),
filename: "bundle.js",
},
devServer: {
publicPath: "/build/",
contentBase: path.resolve(__dirname, "public"),
proxy: {
"/api": "http://localhost:3000/build/bundle.js"
},
port:9000
},
//this environmental variable will either be assigned value of 'production' or 'development' based on which script we run in the package.json
mode: process.env.NODE_ENV,
module: {
//rules is an array that lets me specifiy each case in which a new file type needs to be understood by webpack
rules:[
//rule1 for javascript files that use es6 and jsx
{
//regex to check for any files with the extension js or jsx
test: /\.jsx?/,
//exclude the unessecary node modules folder upon bundling
exclude:/(node_modules)/,
use: {
//specify that we are using babel loader for this rule
loader:"babel-loader",
//specify the presets for this specific loader in options
options: {
presets: ["@babel/preset-env", "@babel/preset-react"]
}
}
},
{
test:/\.scss$/,
exclude: /(node_modules)/,
use:[
{loader: "style-loader"},
{loader: "css-loader"},
{loader: "sass-loader"},
]
},
{
test:/\.css$/,
exclude: /(node_modules)/,
use:[ "style-loader", "css-loader"]
},
{
test: /\.(gif|png|jpe?g|svg|woff(2))$/i,
use: [
{ loader: "file-loader",
options:{
outputPath: "assets",
}
},
{ loader: "url-loader",
options:{
outputPath: "assets",
}
},
{
loader: "image-webpack-loader",
options: {
bypassOnDebug: true,
disable: true,
}
},
]
},
{ test: /\.(jpe?g|png|gif|svg|woff(2))$/i,
include : path.join(__dirname, "assets"), },
]
}
};