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

Cannot determine asset for chunk #106

Closed
dkrutsko opened this issue Mar 22, 2019 · 5 comments · Fixed by #119
Closed

Cannot determine asset for chunk #106

dkrutsko opened this issue Mar 22, 2019 · 5 comments · Fixed by #119

Comments

@dkrutsko
Copy link

Please forgive me if this was already reported, however, I believe my situation to be different.

WARNING in webpack-subresource-integrity: Cannot determine asset for chunk 24, computed="style.js", available=style.css. Please report this full error message along...

This happens because I am extracting CSS styles from style.js using mini-css-extract-plugin and removing the now empty style.js file using webpack-fix-style-only-entries. Here is a sample Webpack configuration demonstrating the issue.

const path = require('path');
const FixStyle = require('webpack-fix-style-only-entries');
const Extract = require('mini-css-extract-plugin');
const HTML = require('html-webpack-plugin');
const SRI = require('webpack-subresource-integrity');

module.exports =
{
	mode: 'production',
	context: path.join(process.cwd(), 'source/'),

	entry:
	{
		style: [ 'styles/style'  ],
		entry: [ 'scripts/entry' ]
	},

	output:
	{
		crossOriginLoading: 'anonymous',
		chunkFilename: '[name]-[chunkhash].js',
		filename: '[name]-[contenthash].js',
		path: path.resolve(__dirname, 'public')
	},

	plugins:
	[
		new FixStyle(),

		new Extract({ filename: '[name]-[contenthash].css' }),

		new HTML
		({
			filename: 'index.html',
			template: 'index.ejs'
		}),

		new SRI({ hashFuncNames: [ 'sha384' ] })
	],

	module:
	{
		rules:
		[
			{
				test: /\.css$/,
				use: [ Extract.loader, 'css-loader' ]
			}
		]
	}
};

I am using webpack-subresource-integrity@1.3.2

@jscheid
Copy link
Collaborator

jscheid commented Mar 25, 2019

Thanks for your bug report. Could you please turn this into a full test case by making a self-contained repository? I've tried making a test case based on the above but it doesn't trigger the warning.

I have a hunch the problem is that webpack-fix-style-only-entries doesn't "fully" remove the JS file from the build. I can see in its source that it deletes the asset, but I think that's not enough. It might also have to remove any references to the assets from other places, in particular from the chunk map.

Anyway, if there's something simple this plugin can do to work around it I'm happy to add that, but first I would need a working test case.

@jscheid
Copy link
Collaborator

jscheid commented Apr 2, 2019

I'm going to close this because without being able to reproduce it there's not much I can do. Please feel free to reopen with some more context, ideally a small repository that demonstrates the issue.

@jscheid jscheid closed this as completed Apr 2, 2019
@jasonrm
Copy link

jasonrm commented Sep 27, 2019

I made a small repo that will reproduce this warning.
https://github.com/jasonrm/wsi-106

@jscheid
Copy link
Collaborator

jscheid commented Sep 27, 2019

@jasonrm fantastic, thanks!

@jscheid jscheid reopened this Sep 27, 2019
jscheid added a commit that referenced this issue Sep 27, 2019
Also, make an effort to ensure our chunkAsset callback runs after
callbacks registered by other plugins.

Closes #106
@jscheid
Copy link
Collaborator

jscheid commented Oct 1, 2019

A fix for this has been released in version 1.3.4. Thanks again for the bug report and the test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants