css-loader: broken escaping

What is the current behavior? The escape symbol \ was lost

.grid            { display: flex; flex-wrap: wrap; }
.grid.\-top      { align-items: flex-start; }
.grid.\-middle   { align-items: center; }
.grid.\-bottom   { align-items: flex-end; }

=>

.grid            { display: flex; flex-wrap: wrap; }\n.grid.-top      { align-items: flex-start; }\n.grid.-middle   { align-items: center; }\n.grid.-bottom   { align-items: flex-end; }\n

What is the expected behavior? Keep the escape symbol \

https://github.com/eeve/test.v1

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 34 (17 by maintainers)

Most upvoted comments

Another similar bug:

input.css

.glyphicon-search:before {
  content: "\e003 \fe0e";
}

output.css

.glyphicon-search:before {
  content: "\E003   \FE0E";
}
  1. Transform to uppercase like @themoch described
  2. Instead of one space there are now 3 spaces between the characters!

I’m having a slightly different issue.

Loader

{
          loader: "css-loader",
          options: {
            sourceMap: true,
            camelCase: "dashes",
            importLoaders: 1,
            modules: true,
            localIdentName: "[name]__[local]___[hash:base64:5]"
          }
        },

input.css

.myStyle {
    content: '\e901';
}

transforms to:

output.css

styles__myStyle___1LKpi {
    content: '\E901';
}

☝️ notice the uppercasing of E. This breaks the unicode used in the font icon

@jschlieber I was on vacation, in the near future I will take care of this, thanks for waiting

Also

body {
  font-family: '微软雅黑'; /* some chinese font name */
}

Just infromation:

.icon-caret-left:before {
   content: '"\\f10c"'
}

Also broken

I’ve got a workaround detailed here

@jschlieber Thanks for issue, confirmed. Let’s wait what says @TrySound (he has access for postcss-* plugins for css-loader)

@evilebottnawi Ok, but what you’re telling me is that i can’t define my css selector as:

.u-m++{
  ...
}

and I’m totally fine with that. But still, if classes are defined like this

.u-m\00002b{
  ...
}

as in the PredixUi CSS library (which btw is valid css). I can’t use it like it is intended, e.g.

<div class="u-m+">
  ...
</div>

because it ends up as

.u-m00002b{
  ...
}

so I would have to use it like this

<div class="u-m00002b">
  ...
</div>

@jschlieber unfortunately no, try to found and fix problem today