-
-
Notifications
You must be signed in to change notification settings - Fork 27k
A way to defined the bundle filename? #4156
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
Comments
Is there any reason why you couldn't get the bundle name from the index.html file in the build directory? |
@sowhatdoido I could parse the index.html and get the generated bundle name from there. But is this the most elegant solution? However when I can't define the bundle name on myself (I like using hashes to avoid caches, too), I could imagine to get it an build time from webpack |
So if you wanted to just get the generate bundle names from the build tool, you can already infer the production location of the script based on the current console output:
Thus your two scripts would just be:
You can then append any hash you want onto the end of this script manually if you wish, though I don't think it's a good idea to try and disable the generated hash just to add your own later. If you want a more automated message solution and are willing to maintain your own CRA repo, you can modify the output in:
|
@sowhatdoido I got this working by writing a custom filter, attached to the build, that reads the actual bundle filename and uses it to replace placeholders in some other json files. Basically this is used for a portal built with CanopyTax single-spa. Each portal service registers itself at the portal (therefore the bundle filename as entry point must be known at runtime). Nevertheless other issues occurred, like single-spa mount/unmount/bootstrap functions were erased during minifying. So I needed to finally reject and strip down the whole built |
Are you sure your functions were missing and not just scoped by webpack? Try attaching the functions to window and see if you can access it. For instance, if you have a function defined as:
I wish you the best of luck! |
@openwms another way in package.json:
|
Something that I was able to do with React Rewired (https://github.com/timarney/react-app-rewired). I will say that if you are really overriding a lot in the future it might be worth ejecting. // config-overrides.js
module.exports = {
webpack: function(config, env) {
if (env === "production") {
//JS Overrides
config.output.filename = 'static/js/[name].js';
config.output.chunkFilename = 'static/js/[name].chunk.js';
//CSS Overrides
config.plugins[4].filename = 'static/css/[name].css';
//Media and Assets Overrides
config.module.rules[1].oneOf[0].options.name = 'static/media/[name].[ext]';
config.module.rules[1].oneOf[3].options.name = 'static/media/[name].[ext]';
}
return config;
}
}; This should take care of the hashes, mapping, and media/asset. Sadly with the way plugins are implemented in an array, I have to use fixed indexes. Also, if you do end up adding more plugins it could mess with those fixed indexes. |
@NathanCH I know this is no the best way, however the
|
From the docs:
"The build is minified and the filenames include the hashes."
Is there a configuration option to define the bundle file name (statically without hash) ? Or is there a way to get the bundle filename during the build?
Need to bypass index.html and load the JS bundle directly from a portal application.
Thanks for a short answer
The text was updated successfully, but these errors were encountered: