-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Scripts: Use cssnano to minimize CSS files with build #33750
Conversation
ef37e94
to
c1b5607
Compare
Size Change: -1.35 kB (0%) Total Size: 1.07 MB
ℹ️ View Unchanged
|
c1b5607
to
288b340
Compare
@@ -24,6 +24,16 @@ const hasBabelConfig = () => | |||
hasProjectFile( '.babelrc' ) || | |||
hasPackageProp( 'babel' ); | |||
|
|||
// See https://cssnano.co/docs/config-file. | |||
const hasCssnanoConfig = () => |
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 discovered in the source code that the list of supported file names is longer that in the docs.
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.
👍 LGTM
@gziolo Wasn't this CSSNano feature included in 17.1.0. I couldn't achieve it! |
No, it's still in the development |
@gziolo I noticed this PR (and one other) appearing under "Enhancements" in the auto-changelog. I wonder is there a better label we could assign to changes like this that are "Tooling" but not necessarily Build Tooling? |
@getdave, I'm open to improvements in this area. Sometimes it's very hard to match existing labels with work that doesn't impact production code. This PR is tricky as well, it was an existing behavior when using I'm sure about one change, we should at least rename |
Description
Follow-up for #33676 and the comment from @ocean90 #33676 (comment):
How has this been tested?
I created a custom block with:
npx wp-create-block example --no-wp-scripts cd example ../node_modules/.bin/wp-scripts build
I updated used CSS files to end with
.css
to ensure that the output is properly minimized.I also ensured that the output of CSS files isn't minified in the dev mode with:
I added
cssnano.config.js
file in the root folder of the project with the following content:I also had to install `cssnano-preset-default' with:
When I run:
I can see that comments in the CSS files are preserved. It means that the custom config is properly loaded when present.
Types of changes
Enhancement.
Checklist:
*.native.js
files for terms that need renaming or removal).