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
|
@ -34,6 +34,7 @@ Thank you to the following contributors who helped with this release:
|
|||
- Docusaurus own search will now search the docs in the correct language & version [\#859](https://github.com/facebook/Docusaurus/pull/859)
|
||||
- Fix phrase emphasis not italicized [\#850](https://github.com/facebook/Docusaurus/pull/850)
|
||||
- Blogpost summary for blog feed is now properly truncated [\#880](https://github.com/facebook/Docusaurus/pull/880)
|
||||
- Fix failure to copy static image if image compression fail [\#887](https://github.com/facebook/Docusaurus/pull/887)
|
||||
|
||||
**Chore and Maintenance**
|
||||
- Remove unused files [\#881](https://github.com/facebook/Docusaurus/pull/881)
|
||||
|
|
|
@ -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