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

css outputs missing entryPoint in metafile #1861

Closed
hardfist opened this issue Dec 17, 2021 · 1 comment
Closed

css outputs missing entryPoint in metafile #1861

hardfist opened this issue Dec 17, 2021 · 1 comment

Comments

@hardfist
Copy link
Contributor

image

It seems the css output missing entryPoint info , which is inconvenient to group css file according to entryPoint, which is important for html-plugin supporting multi page application.

@danprince
Copy link

danprince commented Jul 26, 2022

As far as I can tell, with multiple entry points and EntryNames set to [hash], it's impossible to tell which entry point a CSS file belongs to.

There's a good chance that I've just missed something considering how few people have interacted with this issue, but I'm struggling with the same problem. I'm bundling multiple entrypoints, then injecting the appropriate script/link tags into their associated html files.

From the comment below, it sounds like this was a deliberate decision not to give CSS files an entrypoint property.

// Do not generate "entryPoint" for CSS files that are the result of
// importing CSS into JavaScript. We want this to be a 1:1 relationship
// and there is already an output file for the JavaScript entry point.
if _, ok := file.InputFile.Repr.(*graph.CSSRepr); ok {
jMeta.AddString(fmt.Sprintf("],\n \"entryPoint\": %s,\n \"inputs\": {",
helpers.QuoteForJSON(file.InputFile.Source.PrettyPath, c.options.ASCIIOnly)))
} else {
jMeta.AddString("],\n \"inputs\": {")
}

My current workaround is to ensure that each entry point has a (generated) unique ID that is included in the output file name.

entryPoints = append(entryPoints, api.EntryPoint{
	InputPath:  fmt.Sprintf("page:%s", page.id),
	OutputPath: page.id,
})

Then I piece those entrypoints back together using those IDs when I need to inject scripts.

for _, file := range result.OutputFiles {
	if strings.Contains(file.Path, page.id) {
		switch path.Ext(file.Path) {
		case ".js":
			scripts = append(scripts, file.Path)
		case ".css":
			styles = append(styles, file.Path)
		}
	}
}

@evanw Is there a better solution here and if not, would you accept a PR that added a parentEntryPoint (or similar) to the non-JS assets in the metafile, to help with recombining these bundles?

@evanw evanw closed this as completed in 4bd03f3 Sep 29, 2022
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

No branches or pull requests

2 participants