-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP - Image Optimization #1
base: rysolv
Are you sure you want to change the base?
WIP - Image Optimization #1
Conversation
✅ Deploy Preview for compassionate-saha-53a9e6 ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Added support for commands in build script
|
||
execSync('npm run clean'); | ||
execSync('npm run pre-build -- ' + arg, {stdio:[0, 1, 2]}); | ||
execSync('node index.js ' + arg, {stdio:[0, 1, 2]}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could do this in Bash, rather than in javascript.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was done solely because with npm commands there was no apparent way to pass arguments to the pre-build script if it was done this way: npm run clean && npm run pre-build && node index.js
This exact case was discussed here in much detail and this was the solution recommended in the end: https://stackoverflow.com/a/51401577/8816118
"imagemin-webp": "^6.0.0", | ||
"marked": "^4.0.12", | ||
"npm": "^8.8.0", | ||
"yargs": "^17.4.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What have you done to my beautiful 1 dependency package.json 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Do we need
npm
as a dependency? - I think we can use a shell script instead of the build.js and avoid
yargs
- I think the
i
package came from a typo. Example:npm i i yargs
fs-extra
isn't necessary for just the copy function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Do we need
npm
as a dependency?- I think we can use a shell script instead of the build.js and avoid
yargs
- I think the
i
package came from a typo. Example:npm i i yargs
fs-extra
isn't necessary for just the copy function
Yes i think a few of these are typos. With fs-extra
, i was feeling lazy and just thought it was easier to install a new package instead of write a for loop 🤷
Will fix these
I'll pull this down later and try using a shellscript instead of the build.js (eliminates some packages).
|
Removed fs-extra in favor of a util function
Made some updates in the rysolv branch over the last few weeks (https://github.com/rysolv/markdown_ssg/tree/rysolv. T'll try to get those into master so we can merge with this branch. I've added a few things already (share links, config file, publish (t/f) flag) that should be pretty easy to work in without an issue. |
Added pre-processing functionality which can optimize jpg & png images, which consists of two parts:
The HTML produced for the image looks like:
This helps make sure that if the client does not support webp, it can fall back to the source format safely.
The image also supports title which can be specified in markdown file as a second parameter, following the href of image:
Changes to package.json
The pre-built command now executes
pre-process.js
script which optimize images of specific formats and copies rest of the files as is to the target directory ofbuild/assets
. This script supports optional commands:Example usage:
npm run pre-build -- --dontCompressImages
npm run pre-build -- --dontGenerateWebp
TODO: