Skip to content
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

Introduce an add_editor_style function #32

Open
kadamwhite opened this issue Jan 25, 2021 · 3 comments
Open

Introduce an add_editor_style function #32

kadamwhite opened this issue Jan 25, 2021 · 3 comments
Labels
help wanted Extra attention is needed
Milestone

Comments

@kadamwhite
Copy link
Collaborator

kadamwhite commented Jan 25, 2021

add_editor_style takes a theme-relative path to a stylesheet, and enqueues that stylesheet as an editor asset. Given that hashed filenames can make it challenging to use editor stylesheets, we should consider introducing a helper method which can take the name of a bundle in the manifest and ensure it gets ingested as an editor stylesheet.

Pseudo-code from #35 which we'd want to wrap in an Asset_Loader\add_editor_style() top-level function:

	$editor_stylesheet = Asset_Loader\Manifest\get_manifest_resource(
		get_theme_file_path( 'dist/production-asset-manifest.json' ),
		'tetramino.css'
	);

	add_editor_style( "dist/$editor_stylesheet" );
@kadamwhite
Copy link
Collaborator Author

@Sephsekla Thoughts on whether this would be useful in a 1.0? Re: #40

@kadamwhite kadamwhite added this to the v1.0 Release milestone Jun 16, 2022
@kadamwhite kadamwhite added the help wanted Extra attention is needed label Jun 16, 2022
@goldenapples
Copy link
Contributor

I think this would be more useful if we could get something like humanmade/webpack-helpers#7 finalized, and the time might be right to do that now?

@kadamwhite
Copy link
Collaborator Author

kadamwhite commented Jul 27, 2022

Noting a rough implementation of how the manifest is manually read and the specified asset enqueued on another project

	$json = file_get_contents( $manifest );
	$json_data = json_decode( $json, true );

	if ( isset( $json_data['editor.css'] ) ) {
		add_editor_style( __DIR__ . "/../../build/{$json_data['editor.css']}" );
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants