However, the gulp --production task uses Gulp Rev to append a hash to the style sheet, presumable to prevent caching issues, so I’m not sure how to properly enqueue the style sheet.
So I started poking around…
And on line 97-98 in /lib/assets.php the main css stylesheet is enqueued.
function assets() {
wp_enqueue_style('sage_css', asset_path('styles/main.css'), false, null);
What I don’t understand is how the script above determines the revision hash that’s appended to the filename, or how to use this to enqueue the sheet on the login page.
Not really. All of the stock functions and classes in Sage are now namespaced. It’s explained in that article. Either call functions by their full namespace or use the use keyword at the top of your PHP file.
I added a style sheet for the wp-admin area of my theme. The admin.css file loads in development mode because it’s just calling the admin.css file but on staging and production it does not add the hash to the file name like main-5467tgy.css gets. The JSON file in the dist/ folder does have my admin.css file listed with its corresponding hash file name but in production it still tries to load admin.css which is not in the dist/ folder on the staging and production server. Any idea what the deal is??? Thanks in advance:) Basically I need to call the hashed file on production. here is my style include for the admin.css file
// Adds an admin style to wp-admin - TAS
function load_custom_wp_admin_style() {
wp_register_style( 'sage_css', get_template_directory_uri() . '/dist/styles/admin.css', false, '1.0.0' );
wp_enqueue_style( 'sage_css' );
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );