-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
102 lines (99 loc) · 2.68 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
const HtmlWebpackPlugin = require("html-webpack-plugin");
const path = require("path");
const StringReplacePlugin = require("string-replace-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
const current_mode = process.env.NODE_ENV == 'production' ? 'production' : 'development';
module.exports = () => {
return {
devtool: "source-map",
mode: current_mode,
devServer: {
host: "0.0.0.0",
},
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "build"),
filename: "bundle.js",
},
stats: "errors-only",
plugins: [
new MiniCssExtractPlugin({
filename: "styles.css",
}),
new HtmlWebpackPlugin({ template: "./src/index.html" }),
new StringReplacePlugin(),
new FaviconsWebpackPlugin({
logo: "./src/images/logo.png",
title: "nesrinesghaier.me",
}),
],
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: "babel-loader",
},
},
{
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"sass-loader",
],
},
{
test: /\.html$/,
use: ["html-loader"],
},
{
test: /\.(gif|png|jpg|jpe?g)$/i,
use: [
{
loader: "file-loader",
options: {
name: "images/[name].[ext]",
},
},
"image-webpack-loader",
],
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: ["file-loader"],
},
{
test: /\.svg$/,
use: [
"svg-inline-loader",
{
loader: StringReplacePlugin.replace({
replacements: [
{
pattern: /font-family="'Roboto-Thin'"/gi,
replacement: () => 'font-weight="100"',
},
{
pattern: /font-family="'Roboto-Light'"/gi,
replacement: () => 'font-weight="300"',
},
{
pattern: /font-family="'Roboto-Regular'"/gi,
replacement: () => 'font-weight="400"',
},
{
pattern: /font-family="'Roboto-Black'"/gi,
replacement: () => 'font-weight="900"',
},
],
}),
},
],
},
],
},
};
};