-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
91 lines (89 loc) · 3.06 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
// const { sign } = require('crypto');
module.exports = {
entry: {
home: './src/home/home.js',
login: './src/login/login.js',
admin: './src/admin/admin.js',
parent: './src/parent/parent.js',
teacher: './src/teacher/teacher.js',
signup: './src/signup/signup.js'
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'api/dist/'),
clean: true,
},
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(png|jpe?g|gif|svg)$/, // Match image files
use: [
{
loader: 'file-loader', // Use file-loader for images
options: {
name: '[name].[hash].[ext]', // Output filename pattern
outputPath: 'images/', // Directory to save images in output
},
},
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: './src/home/home.html', // Template file for home page
filename: 'home.html', // Output file for home page
chunks: ['home'], // Bundle for home page
}),
new HtmlWebpackPlugin({
template: './src/login/login.html', // Template file for login page (optional)
filename: 'login.html', // Output file for login page
chunks: ['login'], // Bundle for login page
}),
new HtmlWebpackPlugin({
template: './src/parent/parent.html', // Template file for login page (optional)
filename: 'parent.html', // Output file for login page
chunks: ['parent'], // Bundle for login page
}),
new HtmlWebpackPlugin({
template: './src/teacher/teacher.html', // Template file for login page (optional)
filename: 'teacher.html', // Output file for login page
chunks: ['teacher'], // Bundle for teach page
}),
new HtmlWebpackPlugin({
template: './src/admin/admin.html', // Template file for login page (optional)
filename: 'admin.html', // Output file for login page
chunks: ['admin'], // Bundle for admin page
}),
new HtmlWebpackPlugin({
template: './src/signup/signup.html', // Template file for login page (optional)
filename: 'signup.html', // Output file for login page
chunks: ['signup'], // Bundle for signup page
}),
],
mode: 'development',
devServer: {
static: {
directory: path.join(__dirname, 'dist'), // Serve content from the "dist" directory
},
proxy: [{
context: ['/api'],
target: 'http://127.0.0.1:5000',
}],
compress: true, // Enable gzip compression
port: 5500, // You can specify any port you want
open: true, // Automatically open the browser
historyApiFallback: {
rewrites: [
{ from: /^\/$/, to: '/home.html' }, // Root route serves home.html
],
},
hot: true,
},
};