JavaScript bundling with WP-Scripts and Webpack #467 #468
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This pull request enables the use of wp-scripts in order to compile ES to JS. This intrinsically brings many improvements, among them code minification, transpilation to the most used version of js and an increased compatibility with various devices thanks to browserlists. No stylesheet are available at the moment but in the future it might be useful to know that we can now use also scss
Relevant technical choices
webpack.config.jswas added with a funtion used to "enqueue" scripts, actually is used as suggested by @felixarntz to bundle fallback.js but any other script could be added in this way:and then simply add to module.exports an array with all the needed modules comma separated, like below
module.exports = [first, second, etc]modules/images/webp-uploads/load.phppath since must now point to the minified version inside the dist folder, but I haven't published that one, so if you need it will be a good opportunity for a double check 😉Checklist
[Focus]orInfrastructurelabel.[Type]label.no milestonelabel.