Missing migration instructions to remove hash from file names.
Cannot remove the hash from the build output,
The following was used in earlier versions
build.copyAssets.taskConfig = { excludeHashFromFileNames: true };
This does not work anymore on 1.12.1, as build.copyAssets.taskConfig is undefined.
Feels like this got moved somewhere between 1.8.* to 1.12.* and all the change logs did not mention where this moved to.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 51a6341f-3625-3bd1-151a-8fdb057b7295
- Version Independent ID: ad6d6b0c-3d46-adff-6e71-7ca9fca7dede
- Content: SharePoint Framework v1.12.1 release notes
- Content Source: docs/spfx/release-1.12.1.md
- Product: sharepoint
- Technology: sharepoint-framework
- GitHub Login: @VesaJuvonen
- Microsoft Alias: vesaj
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
Seems like this is now hard-coded in the build tasks:
The WebpackConfigurationGenerator.generateWebpackConfigurationAsync Adds the hash hard-coded now, if making a production build.
This was an issue early on in SPFx 1.1, there were several discussions asking for control over this.
In SPFx 1.3 this configuration was added, and it worked until at least SPFx 1.8 build.copyAssets.taskConfig = { excludeHashFromFileNames: true }
(see thread for reference: https://github.com/pnp/sp-dev-fx-webparts/issues/246)
Now it seems it is hard coded:
if (!options.serveMode && options.production) {
// For future reference, serve mode does not support "contenthash". If the hash
// is included in serve mode, it should be "hash", not "contenthash"
outputFilenameParts.push('_[contenthash]');
}
Would be nice to have a way to control this. Without reopening the entire discussion if it is good or evil, in a simple scenario: some vendors don't want to publish a new package and deploy it on 1000+ customer tenants if they only had to change a label, fix a typo, or other minor changes.
while we are at it - it would also be nice to be able to configure devtool easily in our gulpfile, for those of us who need to have inline maps on dev builds, or have other internal build logic for when to generate source maps.
Thanks!
@juliemturner - didn’t you raise this as an issue when v1.12.0 was released? Was there a “fix” or workaround to address this?
If so, is it something OOTB, or something we need to address in the docs?
Yes/No.... the issue I was seeing during beta release was that the hash filename was regenerating during a gulp serve for every change which led to other issues using a dev build #6838 The issue was addressed but I can't say how, and maybe the outcome is that the option was hard coded as a result. This is not an override I've used, for the normal arguments (although I can see the allure), so I can't say that I have much experience with it. My solution for the requirement is to use SPFx to bootstrap the actual solution in via an external library.
From what I seen the issue was reported in regards of breaking the serve task. So far I can tell by looking at the code this is hard coded now.
I ended up getting it to work like so, but it would be helpful to have the flag for easy control/configuration over this and over the source maps IMHO.
var configureWebPack = build.configureWebpack;
configureWebPack.taskConfig.additionalConfiguration = generatedConfig => {
generatedConfig.devtool = generatedConfig.mode === "development" ? "inline-source-map" : undefined;
generatedConfig.output.chunkFilename = "chunk.[name].js";
generatedConfig.output.filename = "[name].js";
// if we want source map in production
// if (generatedConfig && generatedConfig.optimization && generatedConfig.optimization.minimizer)
// generatedConfig.optimization.minimizer[0].options.sourceMap = true;//allow sourcemaps in production build
return generatedConfig;
};
- edit: updating the code sample with comment from @SibeeshVenu
The answer from @shaipetel helped me but with a minimal change, renaming of configureWebPack to configureWebpack with small letter p.
@andrewconnell @juliemturner I am also facing same issue, is it still not fixed
The answer from @shaipetel helped me but with a minimal change, renaming of
configureWebPacktoconfigureWebpackwith small letterp.
Hahaha - I forgot to add this line to my code sample: var configureWebPack = build.configureWebpack;
That's just the name of my local variable! thanks for pointing this out! I will add it now...
I'm facing the same challenge. The solution from @shaipetel helped, but not for strings-files. These still contain hashes in the filename 😢
Thank you for taking the time to file an issue. We periodically archive older or inactive issues as part of our issue management process, which automatically closes them once they are archived.
If you’d like to understand more about why and how we handle archived (closed) issues, please see Our approach to closed issues.
We appreciate your contribution and if this is still an active issue with the latest SPFx versions, please do resubmit the details. We needed to perform a cleanup, so that we can start with a clean table with a new process. We apologize for the inconvenience this might cause.