-
Notifications
You must be signed in to change notification settings - Fork 33
Add an Asset_Loader class
#87
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
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #87 +/- ##
============================================
- Coverage 60.94% 56.42% -4.52%
- Complexity 81 86 +5
============================================
Files 10 11 +1
Lines 425 459 +34
============================================
Hits 259 259
- Misses 166 200 +34
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
JasonTheAdams
left a comment
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.
@dkotter This is great! Can you please update the CONTRIBUTING.md doc with basic instructions on how to use this?
Docs added in 453c66c, though note it seemed to make more sense in the |
What?
Adds a new
Asset_Loaderclass and sets up our build command to work.Why?
This functionality is currently in #83 but feels like it will be useful for other PRs, so extracting that out from there in hopes of getting this piece merged sooner.
We use
wp-scriptsto build our assets, which outputs both the compiled asset plus an.asset.phpfile. From this file you can pull out the required dependencies as well as a version number. TheAsset_Loaderclass will do this for you automatically instead of having to do this anywhere we want to enqueue things.How?
Asset_Loaderclass with three methods:enqueue_script,enqueue_styleandlocalize_scriptnpm run buildsrcdirectory with an emptyindex.jsfile, so our build command worksTesting Instructions
Locally run
npm i && npm run buildand ensure no errors are output and you see a properbuilddirectory added