-
Notifications
You must be signed in to change notification settings - Fork 4
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
Support hashed production filenames #2
Comments
To this end, I'd like to be able to pass an array of manifests to This would be useful in cases where assets should be served from a dev manifest if one is found, and from a prod manifest if the dev server isn't running. |
@goldenapples if both asset manifests share a file name, asset-loader should behave as expected currently. (This is admittedly undocumented, and makes certain other assumptions). Is the desire for multiple manifests a hard requirement? |
No, other than the fact that it would be nice if the site could load from the dev manifest while the dev server was running, and then fall right back to the prod manifest if not. (Since the dev manifest is usually cleaned on exit, having it at the same file path as the prod manifest would mean overwriting and wiping out the prod manifest when the dev server is started and stopped. As I looked through other open issues, I actually prefer the suggestion you made in #21 (comment): AssetLoader\enqueue_asset(
manifest_file_path(),
'propose-draft-date.js',
[
'handle' => EDITOR_BUNDLE_HANDLE,
'scripts' => [
'wp-components',
'wp-i18n',
'wp-date',
'wp-data',
'wp-edit-post',
],
]
); and letting the My stab at this (in a locked repo, sorry) currently just checks for manifests like this: // The 'asset-manifest.json' file should only be available if the dev server is running.
$is_dev = Manifest\load_asset_manifest( dirname( __DIR__ ) . '/build/asset-manifest.json' );
Asset_Loader\enqueue_asset(
dirname( __DIR__ ) . '/build/' . ( $is_dev ? 'asset-manifest.json' : 'prod-asset-manifest.json' ),
'editor.js'
); ...which is clean enough for me. But it might be nice to provide a helper function that, given an array of manifest files, returns the first one that exists and is readable? |
I can absolutely get behind a helper function, thanks for that suggestion Thinking through what this would look like: |
This has been resolved since the issue was first opened. |
Currently the way we match files on disk is by direct filename match, e.g.
theme.js
. This breaks down if the Webpack config specifies a hashed value in the output filename. We should support loading hashed files in production mode, or clarify explicitly that it is prohibited if it becomes too complex.The text was updated successfully, but these errors were encountered: