-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.js
103 lines (101 loc) · 3.08 KB
/
webpack.dev.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
/* eslint-disable */
const path = require('path');
const {merge} = require('webpack-merge');
const common = require('./webpack.common.js');
const HtmlWebpackPlugin = require('html-webpack-plugin');
// const HtmlWebpackRootPlugin = require('html-webpack-root-plugin');
const fs = require('fs');
module.exports = merge(common, {
mode : "development",
output: {
path: path.resolve(__dirname,'build'),
filename: "app.bundle.dev.js",
publicPath: "/"
},
module: {
rules: [
//js
{
test: /\.m?j(s|sx)$/i,
exclude: /node_modules/,
use: [
{
loader: "babel-loader",
}
]
},
//styles
{
test: /\.s[ca]ss$/i,
use: [
"style-loader", // Inject CSS into the DOM.
{
loader: "css-loader",
options: {
importLoaders: 1,
}
}, // The css-loader interprets @import and url() like import/require() and will resolve them.
"sass-loader", // Loads a Sass/SCSS file and compiles it to CSS.
]
},
{
test: /\.css$/i,
use: [
"style-loader",
"css-loader",
"postcss-loader",
]
},
//html
{
test: /\.html$/,
use: [
{
loader: "html-loader",
options: {
// sources: {},
minimize: true
}
}
]
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource',
},
{
test: /\.(pdf)$/i,
type: 'asset/resource',
generator : {
filename : 'documents/[name][ext][query]',
}
},
]
},
plugins: [
new HtmlWebpackPlugin({
title: "Phat's portfolio",
filename: "index.html",
meta: {
viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'
},
minify: true,
showErrors: true,
template: path.resolve(__dirname, 'src/index.html'),
favicon: "./Assets/money_plant.png"
}),
],
devtool: "cheap-module-source-map",
devServer: {
watchFiles: ['src/**/*'],
liveReload: true,
allowedHosts: 'all',
static: {
directory: path.resolve(__dirname, "build"),
publicPath: "/"
},
historyApiFallback: true,
host: "127.0.0.1",
port: 5000,
}
})