Merged
Conversation
Change webpack config to use @wordpress/scripts.
the entrypoint detection should not care if block entrypoints are present, as these are handled by wp-scripts. it can continue to throw an error provided we catch this in the correct location
Ensure block and non-block entrypoints can be built together
Remove css-loader and mini-css-extract-plugin packages
…onfig to allow CSS/JS to build
fix: adds context path assignment to webpack configs
* fix: remove custom image rules * test: update svg import syntax in example site * chore: version bump
* fix: ensure script module config uses correct source path for project * chore: version bump
This reverts commit 2743aed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR updates the build tools to 2.0.0.
Fixes #106
Fixes #109
Fixes #139
This has been tested extensively on projects via alpha release tags, and is ready to become the default version. Within this PR I've updated the documentation to include an upgrade guide which outlines the main changes and issues a person may experience when upgrading an existing project from v1 to v2, copied below:
Upgrading from Build Tools v1
Handling lint differences
There are several new lint rules in place that weren't present in v1 of the build-tools, and some of these can generate a lot of noise. However many are also automatically fixable. If you're upgrading an existing project, presuming you have set up prettier and eslint to use our config, you can run
npx eslint ./src --fixto detect and fix all auto-fixable issues.builddirectory is nowdistThis aligns with wp-scripts naming conventions and ensures that wp-scripts works as expected. For example, certain actions will auto-ignore files in the
distdirectory.asset-settings.phpis no longer usedv1 of the build tools generated a file at
inc/asset-settings.php. This is no longer created, so any references to this file in your project should be removed. This file is usually not tracked in VCS, but if it is, or if it exists for you locally, you should remove it.SVG import syntax has changed
If you're using SVG files in JavaScript, the syntax to import assets has changed to match wp-scripts. There are two ways to import an SVG:
import { ReactComponent as IconComponent } from './icon.svg';import iconURL from './icon.svg';Static directory is no longer copied to
distWe previously used a
src/staticdirectory to copy files fromsrctobuild. This is no longer required.Fonts and images imported into JavaScript files will be transformed and moved to
buildregardless of where they are located. Any other files that you want to have available should reside in astaticdirectory which is not inside of thesrcdirectory, and not processed at all by the tooling.Block registration
Block registration has been simplified due to the use of wp-scripts. Block source code should reside in
src/blocks/{block-name}and include ablock.jsonfile which references assets by file path. JavaScript, (S)CSS and even PHP should be located in the block directory, and the tooling will handle processing of all files intodist/blocks/{block-name}.You can review the WordPress docs for more information on how
block.jsonand assets work.