Refactor webpack configuration to copy index.html to payment directory, enhancing clarity in log messages and ensuring proper directory structure for asset management.
This commit is contained in:
@@ -84,19 +84,19 @@ const CopyAssetsPlugin = {
|
|||||||
console.error('Error copying favicon:', err);
|
console.error('Error copying favicon:', err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy index.html to payment/success directory for callback
|
// Copy index.html to payment/success file for callback
|
||||||
const indexSrc = path.resolve(__dirname, 'dist/index.html');
|
const indexSrc = path.resolve(__dirname, 'dist/index.html');
|
||||||
const paymentSuccessDir = path.resolve(__dirname, 'dist/payment/success');
|
const paymentDir = path.resolve(__dirname, 'dist/payment');
|
||||||
const paymentSuccessDest = path.resolve(__dirname, 'dist/payment/success/success');
|
const paymentSuccessDest = path.resolve(__dirname, 'dist/payment/success');
|
||||||
try {
|
try {
|
||||||
// Create payment/success directory if it doesn't exist
|
// Create payment directory if it doesn't exist
|
||||||
if (!fs.existsSync(paymentSuccessDir)) {
|
if (!fs.existsSync(paymentDir)) {
|
||||||
fs.mkdirSync(paymentSuccessDir, { recursive: true });
|
fs.mkdirSync(paymentDir, { recursive: true });
|
||||||
}
|
}
|
||||||
cpSync(indexSrc, paymentSuccessDest);
|
cpSync(indexSrc, paymentSuccessDest);
|
||||||
console.log('Index.html copied to payment/success/success successfully');
|
console.log('Index.html copied to payment/success file successfully');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error copying index.html to payment/success/success:', err);
|
console.error('Error copying index.html to payment/success file:', err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user