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

Empty content with "concat | fingerprint" #6309

Closed
brunoamaral opened this issue Sep 5, 2019 · 6 comments · Fixed by #6311

Comments

@brunoamaral
Copy link
Contributor

commented Sep 5, 2019

I was using the code below and it worked until Hugo 0.57.x.

{{- $print := resources.Get "css/print.css" | resources.Fingerprint -}}
<link href="{{- $print.Permalink -}}" media="print" rel="stylesheet" />

{{ $fontawesome := resources.Get "fontawesome-free-5.9.0-web/scss/fontawesome.scss" | resources.ToCSS (dict "enableSourceMap" false "outputStyle" "compressed") }}
{{ $brands := resources.Get "fontawesome-free-5.9.0-web/scss/brands.scss" | resources.ToCSS (dict "enableSourceMap" false "outputStyle" "compressed") }}
{{ $regular := resources.Get "fontawesome-free-5.9.0-web/scss/regular.scss" | resources.ToCSS (dict "enableSourceMap" false "outputStyle" "compressed") }}

{{- $bootstrap := resources.Get "css/bootstrap.min.css" -}}
{{- $nowUi := resources.Get "scss/now-ui-kit.scss" | resources.ToCSS (dict "enableSourceMap" false "outputStyle" "compressed") -}}

{{- $style := slice $bootstrap $nowUi $montserrat $fontawesome $brands $regular | resources.Concat "css/style.css" | resources.Fingerprint -}}
<link href="{{- $style.Permalink -}}" rel="stylesheet">

In 0.58.0, it just returns an empty css file on hugo server and build.

@bep bep added this to the v0.58.1 milestone Sep 5, 2019

@bep bep removed the NeedsInvestigation label Sep 5, 2019

@bep

This comment has been minimized.

Copy link
Member

commented Sep 5, 2019

I see many CSS files constructed in the above -- all of them empty?

@kascme

This comment has been minimized.

Copy link

commented Sep 5, 2019

I have a similar problem, but with JavaScript. The generated file is empty if I use ... | resources.Fingerprint. Without fingerprinting I get the expected output. However, I have not fully invested the issue as it does not happen with all files in my case

@brunoamaral

This comment has been minimized.

Copy link
Contributor Author

commented Sep 5, 2019

Just tried the whole list of files and they all work isolated. The main style.css works only if I remove .Fingerprint from the variable's settings.

@bep

This comment has been minimized.

Copy link
Member

commented Sep 5, 2019

I'm sorry for the breakage, but I cannot reproduce this. I have plenty of tests in this area, including many working sites that still works on Hugo 0.58.

@bep

This comment has been minimized.

Copy link
Member

commented Sep 5, 2019

OK, nevermind, I can reproduce it. A stupid workaround would be to minify it before you fingerprint it.

@bep bep added Bug and removed NeedsInvestigation labels Sep 5, 2019

@bep bep changed the title Hugo pipes returning an empty css file Empty content with "concat | fingerprint" Sep 5, 2019

bep added a commit to bep/hugo that referenced this issue Sep 5, 2019
Fix concat with fingerprint regression
In Hugo 0.58 we optimized the transformers that only adjusted metadata, e.g. the fingerprint.

This depended on the source readers implementing `io.ReadSeeker`.

The reader produced by `concat` did that, but the implementation was buggy.

This commit fixes that.

Fixes gohugoio#6309

@bep bep closed this in #6311 Sep 5, 2019

bep added a commit that referenced this issue Sep 5, 2019
Fix concat with fingerprint regression
In Hugo 0.58 we optimized the transformers that only adjusted metadata, e.g. the fingerprint.

This depended on the source readers implementing `io.ReadSeeker`.

The reader produced by `concat` did that, but the implementation was buggy.

This commit fixes that.

Fixes #6309
@bep

This comment has been minimized.

Copy link
Member

commented Sep 6, 2019

Just so people don't read this and think that Hugo's test suite is full of holes:

This did work before this commit:

{{ $combined := slice $a $b $c | resources.Concat "bundle/concat.txt" | minify | fingerprint }}

But due to a bug in the io.Reader produced by concat (it could not be reset), this produced empty files:

{{ $combined := slice $a $b $c | resources.Concat "bundle/concat.txt" | fingerprint }}

I had tests and sites covering the first variant, but not the latter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.