mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-19 12:07:00 +02:00
fix: copy static image as it is if image compression fail (#887)
* fix: fail to copy static image due to image compression on build * add changelog
This commit is contained in:
parent
ef80581e8e
commit
5fae14a2bf
2 changed files with 8 additions and 5 deletions
|
@ -247,11 +247,9 @@ async function execute() {
|
|||
!commander.skipImageCompression
|
||||
) {
|
||||
const parts = normalizedFile.split(`${sep}static${sep}`);
|
||||
const targetDirectory = join(
|
||||
buildDir,
|
||||
parts[1].substring(0, parts[1].lastIndexOf(sep))
|
||||
);
|
||||
mkdirp.sync(path.dirname(targetDirectory));
|
||||
const targetFile = join(buildDir, parts[1]);
|
||||
const targetDirectory = path.dirname(targetFile);
|
||||
mkdirp.sync(targetDirectory);
|
||||
imagemin([normalizedFile], targetDirectory, {
|
||||
use: [
|
||||
imageminOptipng(),
|
||||
|
@ -261,6 +259,10 @@ async function execute() {
|
|||
}),
|
||||
imageminGifsicle(),
|
||||
],
|
||||
}).catch(error => {
|
||||
// if image compression fail, just copy it as it is
|
||||
console.error(error);
|
||||
fs.copySync(normalizedFile, targetFile);
|
||||
});
|
||||
} else if (!fs.lstatSync(normalizedFile).isDirectory()) {
|
||||
const parts = normalizedFile.split(`${sep}static${sep}`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue