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

Color names in CSS font-family attribute being convered to HEX code only on generate #6306

Closed
stevecomrie opened this issue Aug 26, 2019 · 1 comment · Fixed by #7763
Closed

Comments

@stevecomrie
Copy link

Version

v2.9.1

Reproduction link

https://clever-franklin-bb11e3.netlify.com/

Steps to reproduce

  • Start with a fresh NuxtJS project (yarn or npm, doesn't matter)
  • Edit the pages/index.vue file and replace the value for the font-family attribute on the .title element with "Archivo Black"
  • Generate the site
  • View the dist/index.html file

What is expected ?

The font-family for the .title style should be 'Archivo Black'

What is actually happening?

The value is actually reading 'Archivo #000'

Additional comments?

This error was brought up before here:
#5778

But it was closed because the issue couldn't be replicated.

I've provided a github repo with only the above steps replicated:
https://github.com/stevecomrie/nuxtjs-font-replacement-bug

And to eliminate any chance of the issue being with build modules being out of date on my development machine, I've also used Netlify to automate the deployment of that github repo:
https://clever-franklin-bb11e3.netlify.com

The issue does not occur when running a local development server -- only when generating the site for production.

This bug report is available on Nuxt community (#c9682)
@ghost ghost added the cmty:bug-report label Aug 26, 2019
@manniL manniL added the pending label Aug 26, 2019
@manniL
Copy link
Member

manniL commented Aug 26, 2019

Can't reproduce it with yarn build && yarn start as well, but with yarn generate. Might be a minification problem 🤔

UPDATE

Yes, it's an issue with the minification. https://github.com/kangax/html-minifier/ replaces the color when minifying CSS. To avoid this, set build.html.minify to

{
  collapseBooleanAttributes: true,
  decodeEntities: true,
  minifyCSS: false, // This is not the default
  minifyJS: true,
  processConditionalComments: true,
  removeEmptyAttributes: true,
  removeRedundantAttributes: true,
  trimCustomFragments: true,
  useShortDoctype: true
}

UPDATE 2

Interestingly, the underlying repo example works well with font families in singlequotes but not without quotes.

The following code does work on the test page (but still not via yarn generate):

<html>
<head>
<style>
.container {
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.title {
  font-family: 'Archivo Black', 'Source Sans Pro', -apple-system, BlinkMacSystemFont,
    'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  display: block;
  font-weight: 300;
  font-size: 100px;
  color: #35495e;
  letter-spacing: 1px;
}
</style>

</head>

<body>
<h1 class="title"> Foo </h1>
</body>
</html>

UPDATE 3

The A similar issue is already picked up in clean-css/clean-css#1058, a workaround PR is available in clean-css/clean-css#1077

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

Successfully merging a pull request may close this issue.

4 participants