-
Notifications
You must be signed in to change notification settings - Fork 82
Assets: Build JS & CSS files #1674
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
base: trunk
Are you sure you want to change the base?
Conversation
5cbacb0
to
957ab46
Compare
This PR seem to change the way how we work with "static" js. Can you maybe add a switch, to use the asset file in dev mode ( maybe using https://developer.wordpress.org/reference/functions/wp_get_environment_type/) and/or write a doc about how to best use it in the daily development process. |
Good call on updating the docs! It does change the way we work with these files, bringing it inline with how blocks are developed. It shouldn't be necessary to switch modes as long as these files get edited while running With that in mind, I do wonder if it would make sense to move these js and css files into |
let's move them to source to be consistent. maybe we should use a proper folder structure and mimic the block file pattern a bit? |
Yeah, happy to move them to src. I'm not sure there's much benefit to creating a fake block structure around them. |
Not a fake block structure, but more descriptive folder structures and simpler file names. There is no need to prefix them for example. |
Cool, yeah I think I did that. |
I am not sure about the folder structure... This is a bit inconsistent... Shouldn't we reuse the folder structure of the blocks even if it is not a block? Like:
and
|
Oh, I see! I think we could do something like that. Let me experiment with it a bit. The limiting factor will be the discoverability of entry points. Currently we can say "any file in /js and /css is an entry point" and don't have to manually add new ones to Webpack. If we were to break it out in arbitrary folders, that would no longer work. However, we could try moving all blocks into a |
I would do the /blocks folder "hack"! We have so many points in the code where we decided to be explicit over implicit, so I see no issue to properly configure every new asset we add!?! |
Also add RTL support for stylesheets and post preview.
2ac4725
to
3c33d72
Compare
The good news: I managed to make it work to combine scripts and styles in folders and still be recognized as entry points. |
why do the blocks have to be in the blocks subfolder? why not have everything on one level? |
Practically because blocks are built differently than the other JS/CSS file. It also helps with organization, alongside the wp-admin and embed folders |
Building on #1673, this PR adds the JS and CSS files in
/assets
to the entry points ofnpm run build
.It minimizes the files and adds RTL support for stylesheets. This PR also adds RTL support to the post preview.
Proposed changes:
/assets
entrypoints.After
Changelog entry
Changelog Entry Details
Significance
Type
Message
Post Preview now supports RTL languages.
Embed and wp-admin styles are optimized for RTL languages.