-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.cjs
More file actions
55 lines (54 loc) · 1.6 KB
/
webpack.config.cjs
File metadata and controls
55 lines (54 loc) · 1.6 KB
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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
// const TerserWebpackPlugin = require('terser-webpack-plugin');
module.exports = {
entry: {
index: './src/web/index.js',
view: './src/web/view.js'
}, // Entry point of your application
output: {
filename: '[name].[contenthash:8].js',
path: path.resolve(__dirname, 'dist'), // Output directory
},
mode: 'production', // Set to 'development' for non-minified output
plugins: [
new HtmlWebpackPlugin({
template: './resources/index.html', // Path to your HTML template
filename: 'index.html', // Output HTML filename
chunks: ['index']
}),
new HtmlWebpackPlugin({
template: './resources/view.html', // Path to your HTML template
filename: 'view.html', // Output HTML filename
chunks: ['view']
}),
new CopyWebpackPlugin({
patterns: [
// Add patterns for files you want to copy during the build
{ from: 'gen', to: '' }, // Example: Copy files from src/static to dist/static
],
}),
new MiniCssExtractPlugin({
filename: '[name].[contenthash:8].css' // The name of the extracted CSS file
})
],
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"]
}, {
test: /\.html$/,
use: "html-loader"
}, {
test: /\.(jpg|jpeg|png|gif|svg)$/,
type: 'asset',
}
]
},
devServer:{
host: '0.0.0.0'
}
};