Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #4121
Closed
Open
Issue created Mar 07, 2018 by Administrator@rootContributor

Prod config produces invalid font-family values in minified CSS

Created by: veltman

Is this a bug report?

Yes

Steps to Reproduce

  1. Import a stylesheet with a font-family declaration that includes a quoted, multiple-word font name that includes a generic CSS font family keyword as its first word (monospace, cursive, serif, etc.). For example:
body {
  font-family: "Monospace Number";
}
div {
  font-family: "Primary Font", "Cursive Font";
}
  1. Build a minified bundle with npm run build.

Expected Behavior

The font declarations are intact.

Actual Behavior

  1. cssnano's minification will drop the quotes, leading to:

body{font-family: Monospace Number}div{font-family: Primary Font,Cursive Font}

These are both invalid font-family value because of the keyword + lack of quotes. Confirmed they get ignored as invalid in Chrome 64, Firefox 58, and Safari 11.

Related issues

https://github.com/ben-eb/cssnano/issues/434
https://github.com/ben-eb/cssnano/issues/439

Suggested fix

I suspect this comes up a fair amount because "Monospace Number" is used throughout some versions of the Ant Design stylesheet. It may also affect other weird name scenarios, like unicode characters in a font name or, the edgiest of edge cases, someone who used a custom font named, e.g., "serif" (I believe the spec allows this if it's quoted!).

Given that it's unclear whether cssnano will change its default behavior, this could be fixed by updating webpack.config.prod.js to pass an option through to preserve the quotes:

// Old
minimize: true,

// New
minimize: { minifyFontValues: { removeQuotes: false } },

If this sounds reasonable I can send a PR.

Assignee
Assign to
Time tracking