feat: update CopyAssetsPlugin to exclude fonts during asset copying

This commit is contained in:
sebseb7
2025-07-20 14:47:57 +02:00
parent 1fd6ed85b6
commit d3998133e5

View File

@@ -64,12 +64,20 @@ class GitHashJsonPlugin {
const CopyAssetsPlugin = {
apply: (compiler) => {
compiler.hooks.afterEmit.tap('CopyAssetsPlugin', () => {
// Copy assets directory
// Copy assets directory but exclude fonts (webpack handles fonts with hashed names)
const assetsSrc = path.resolve(__dirname, 'public/assets');
const assetsDest = path.resolve(__dirname, 'dist/assets');
try {
cpSync(assetsSrc, assetsDest, { recursive: true });
console.log('Assets copied successfully');
// Copy all assets except fonts
const items = fs.readdirSync(assetsSrc);
for (const item of items) {
if (item !== 'fonts') {
const srcPath = path.join(assetsSrc, item);
const destPath = path.join(assetsDest, item);
cpSync(srcPath, destPath, { recursive: true });
}
}
console.log('Assets copied successfully (fonts excluded - handled by webpack)');
} catch (err) {
console.error('Error copying assets:', err);
}