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

enableIntegrityHashes and configureFilenames can conflict together #1340

Closed
Kocal opened this issue Sep 16, 2024 · 1 comment
Closed

enableIntegrityHashes and configureFilenames can conflict together #1340

Kocal opened this issue Sep 16, 2024 · 1 comment
Labels
Bug Bug Fix

Comments

@Kocal
Copy link
Member

Kocal commented Sep 16, 2024

While working on #969, I've found that the Encore.enableIntegrityHashes() feature was doing nothing, because my Encore.configureFilenames() configuration:

Encore.configureFilenames({
    js: '[name].js?v=[contenthash:8]',
    css: '[name].css?v=[contenthash:8]',
    assets: 'assets/[name].[ext]?v=[contenthash:8]',
})

Using a query-parameter to store contenthash instead of the filename itself, is a strategy mentioned in #1266.

If I had console.log({outputPath: webpackConfig.outputPath, file, publicPath, filePath }) below
lines https://github.com/symfony/webpack-encore/blob/main/lib/plugins/entry-files-manifest.js#L55-L58, it outputs:

{
  outputPath: '/Users/kocal/path-to-app/public/build',
  file: '/build/app.js?v=3af532f5',
  publicPath: '/build/',
  filePath: '/Users/kocal/path-to-app/public/build/app.js?v=3af532f5'
}

The next line fs.existsSync(filePath) can only returns false, because it will try to find a file explicitly named app.js?v=3af532f5, which... does not exist. But app.js file does exist!

If I remove my custom filenames formats, as expected I can see the integrity hashes in entrypoints.json file.


What should we do?

Should we check if ? is present in the filename, and if yes, remove ? and everything after?
Should we keep the actual behavior but log a warning instead?

@Kocal Kocal added the Bug Bug Fix label Sep 16, 2024
@stof
Copy link
Member

stof commented Sep 16, 2024

Duplicate of #1269

@stof stof marked this as a duplicate of #1269 Sep 16, 2024
@stof stof closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug Fix
Projects
None yet
Development

No branches or pull requests

2 participants