You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using wp-scripts for my plugin. I have a folder block-mods contain only additional css loading for core blocks with PHP wp_enqueue_block_style function. Now the problem is my CSS use PostCSS and i would like to have some preprocessing, but how is it possible since its not included in block.json or any javascript?
What is your proposed solution?
I would like to see better customize options for wp-scripts, especially entry points, chunk names and PHP files to copy.
Maybe have a json configuration could be a option? Currently my workaround is using a custom webpack.config.js and I hope someone come up with a better idea?
Anyway. I think this must be a quite common scenario for theme builders? Another thing I dislike is the filenames and chunks wp-scripts generates. It's always a big surprise what files finally come out in build. For example. I have a file index.js and it includes view.css and custom.css - I wish wp-scripts only creates a single css for anything included in index.js
Maybe the @wordpress/scripts could include the remove empty scripts plugin and have additional flags to ease it's usage for themes assets like you describe (core blocks overrides or javascript files).
Maybe the @wordpress/scripts could include the remove empty scripts plugin and have additional flags to ease it's usage for themes assets like you describe (core blocks overrides or javascript files).
I left a comment on a similar topic today #55936 (comment). Let's explore how we can expand the automatic discovery of JS and CSS entry points for both plugins and themes in wp-scripts build. This tool can be flexible enough to support most of the developers in the community.
The only challenge would be arriving at the patterns for detecting CSS files. Are there any existing patterns?
This is not an exhaustive research, but it appears that assets is a common directory name.
I have ommitted styles.css which may contain styles or only the theme headers.
When people build bespoke themes and choose to include custom blocks in their theme, I don't know where they put their blocks. I would say either a blocks directory inside or next to the assets directory.
I use the same code then @benoitchantre but I found it in the gutenberg source. I think it would be already helpful if there is a simple helper function we can import in our webpack.config.js and set the glob path with a argument.
I believe the the assets/ folder is used for historical reasons? With a bundler prefer nowadays src/ and dist/ because it's clear if preprocessing is required. @gziolo For automatic detection, how about mystyle.block.css and searching anything with *.block.css?
We're moving away from @wordpress/scripts current build behavior towards @wordpress/build, a more opinionated approach. See #72032 for more details.
If you need a very customized setup, don't rely on Core tools and use your own tooling. There are multiple valid choices in the community to pick from.
What is the consequence for the @wordpress/scripts package? Will it still be maintained?
Yes, but the plan is to probably make its "build" command use @wordpress/build at some point (so a dev breaking change). The exact migration plan is still tbd
Activity
chimok commentedon Sep 15, 2023
I'm using
postcss-clifor now because what I need is more like a task runner instead bundler.Anyway. I think this must be a quite common scenario for theme builders? Another thing I dislike is the filenames and chunks
wp-scriptsgenerates. It's always a big surprise what files finally come out in build. For example. I have a file index.js and it includes view.css and custom.css - I wish wp-scripts only creates a single css for anything included in index.jsbenoitchantre commentedon Nov 24, 2023
Here's what I use, based on https://gist.github.com/justintadlock/043f7fedb436a80174da27ee0c5fa53b
webpack.config.js
package.json
{ "devDependencies": { "@wordpress/scripts": "^26.16.0", "path": "^0.12.7", "webpack-remove-empty-scripts": "^1.0.4" }, "prettier": "@wordpress/prettier-config", "scripts": { "build": "wp-scripts build --webpack-src-dir=blocks --output-path=dist/blocks --webpack-copy-php", "check-engines": "wp-scripts check-engines", "format": "wp-scripts format", "lint:css": "wp-scripts lint-style", "lint:js": "wp-scripts lint-js", "start": "wp-scripts start --webpack-src-dir=blocks --output-path=dist/blocks --webpack-copy-php" } }Maybe the @wordpress/scripts could include the remove empty scripts plugin and have additional flags to ease it's usage for themes assets like you describe (core blocks overrides or javascript files).
gziolo commentedon Nov 24, 2023
I left a comment on a similar topic today #55936 (comment). Let's explore how we can expand the automatic discovery of JS and CSS entry points for both plugins and themes in
wp-scripts build. This tool can be flexible enough to support most of the developers in the community.The only challenge would be arriving at the patterns for detecting CSS files. Are there any existing patterns?
benoitchantre commentedon Dec 4, 2023
This is not an exhaustive research, but it appears that
assetsis a common directory name.I have ommitted
styles.csswhich may contain styles or only the theme headers.When people build bespoke themes and choose to include custom blocks in their theme, I don't know where they put their blocks. I would say either a
blocksdirectory inside or next to the assets directory.From https://github.com/10up/wp-scaffold/tree/trunk/themes/10up-theme/
From https://github.com/justintadlock/first-draft/
From https://github.com/OllieWP/ollie
From https://github.com/wpengine/frost
From https://github.com/WordPress/twentytwentyfour/
From https://github.com/WordPress/twentytwentyone/
chimok commentedon Feb 2, 2024
I use the same code then @benoitchantre but I found it in the gutenberg source. I think it would be already helpful if there is a simple helper function we can import in our webpack.config.js and set the glob path with a argument.
I believe the the
assets/folder is used for historical reasons? With a bundler prefer nowadayssrc/anddist/because it's clear if preprocessing is required. @gziolo For automatic detection, how about mystyle.block.css and searching anything with *.block.css?youknowriad commentedon Nov 18, 2025
We're moving away from @wordpress/scripts current build behavior towards
@wordpress/build, a more opinionated approach. See #72032 for more details.If you need a very customized setup, don't rely on Core tools and use your own tooling. There are multiple valid choices in the community to pick from.
benoitchantre commentedon Nov 18, 2025
What is the consequence for the @wordpress/scripts package? Will it still be maintained?
youknowriad commentedon Nov 18, 2025
Yes, but the plan is to probably make its "build" command use
@wordpress/buildat some point (so a dev breaking change). The exact migration plan is still tbdbenoitchantre commentedon Nov 18, 2025
Thank you