-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
64 lines (61 loc) · 1.6 KB
/
webpack.config.js
File metadata and controls
64 lines (61 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
56
57
58
59
60
61
62
63
64
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const fs = require('fs');
module.exports = {
mode: 'development',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'build'),
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react']
}
}
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html'
}),
{
apply: (compiler) => {
compiler.hooks.afterEmit.tap('CopyAssetsPlugin', () => {
const srcDir = path.join(__dirname, 'public');
const destDir = path.join(__dirname, 'build');
// Copy logo and other assets
const filesToCopy = ['logo.png', 'task-logo.png'];
filesToCopy.forEach(file => {
const src = path.join(srcDir, file);
const dest = path.join(destDir, file);
if (fs.existsSync(src)) {
fs.copyFileSync(src, dest);
}
});
// Also copy icon
const iconSrc = path.join(srcDir, 'logo.png');
const iconDest = path.join(destDir, 'icon.png');
if (fs.existsSync(iconSrc)) {
fs.copyFileSync(iconSrc, iconDest);
}
});
}
}
],
devServer: {
port: 8080,
historyApiFallback: true
}
};