question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MiniCssFile emits `=` symbol to the end of the url

See original GitHub issue
  • Operating System: MacOs bleeding edge
  • Node Version: 12.10.0
  • NPM Version: 6.10.3
  • webpack Version: 4.46.0
  • mini-css-extract-plugin Version: 1.3.6

Expected Behavior

Hashes on included resources in css (e.g. url(font)) should be the same inside css and js file

Actual Behavior

css files has this hash

src:url(https://static.pychat.org/font/fontello.eot?21a4cc50be58c1
f0d8b8941292120311=)

js file has this hash

/font/fontello.eot?21a4cc50be58c1f0d8b8941292120311

Code

To reproduce we need

  1. To pass publicPath to MiniCssExtractPlugin options that is an absolute url
  2. on fileLoader add name which has [contenthash] in it
// webpack.config.js

module: {
 rules : [
   {
      test: /\.sass$/,
      use: [
         {
           loader: MiniCssExtractPlugin.loader,
           publicPath: "https://static.pychat.org"
         },
         'css-loader',
        sassOptionsGlobal,
      ]
   }
 ]
}

How Do We Reproduce?

git clone https://github.com/akoidan/pychat
cd pychat
git checkout a8d6d3c3575674c35c12e167cd40e908a451f36c
cd frontend
cp pychat.org.json production.json
nvm use
yarn install
yarn prod
cat dist/sw.js # check asssets. e.g. fontello.woff2 /font/fontello.woff?214a56
cat dist/main.css # check asssets. e.g. fontello.woff2. in my repo it's url(https://static.pychat.org/font/fontello.woff?214a563509566562229f1193074cf803=) format("woff")

Tips: If I remove public path option from extractminicss plugin this = symbol is no longer present P.S> webpack config is located in builder.js

The diversion from origin source causes a lot of issues in service worker, since I rely that file assets should be the same.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
alexander-akaitcommented, Feb 15, 2021

Yep, comment optimize-css-assets-webpack-plugin plugin in your builder.js script and all works fine, optimize-css-assets-webpack-plugin uses cssnano under the hood (so bug in cssnano), there is good and bad news: good - I am main maintainer of cssnano, bad - I don’t have time and money to continue work on cssnano 😞 I understand it is not your problem, but if you send a PR I will look at this

Bug here https://github.com/cssnano/cssnano/blob/master/packages/postcss-normalize-url/src/index.js#L15, normalize-url adds =, debug:

console.log(url); // https://static.pychat.org/img/cropperjs/bg.png?d706d3
console.log(normalizedURL); // https://static.pychat.org/img/cropperjs/bg.png?d706d3=

maybe we should open an issue in normalize-url package, I think nothing to fix here

0reactions
alexander-akaitcommented, Feb 18, 2021

Let’s close, nothing to fix here

Read more comments on GitHub >

github_iconTop Results From Across the Web

url() - CSS: Cascading Style Sheets - MDN Web Docs
The url() CSS function is used to include a file. The parameter is an absolute URL, a relative URL, a blob URL, or...
Read more >
MiniCssExtractPlugin - webpack
If true, emits a file (writes a file to the filesystem). If false, the plugin will extract the CSS but will not emit...
Read more >
10 Helpful VS Code Extensions for HTML & CSS - YouTube
Visual Studio Code has quickly become the code editor of choice among many developers. The vast extension library is one of its main...
Read more >
How to Bundle a Simple Static Site Using Webpack - SitePoint
And webpack will create a bundle.js file in the dist folder. ... Then click and hold the reload symbol next to the address...
Read more >
The complete best practices for minifying CSS - LogRocket Blog
Minifying CSS files is more nuanced than you might think at first. Learn the various minification tools, how to determine and remove unused ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found