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.

Community Feedback Requested

See original GitHub issue

Hi, everyone. One of the biggest points of confusion with Laravel Mix stems from the fact that it will automatically rewrite your CSS urls(). Now, this is simply a Webpack feature, and has nothing to do with Mix, specifically; however, I understand that it can be confusing to newcomers.

An Example

Imagine that we want to compile a bit of Sass.

.example {
    background: url('../images/thing.png');
}

Notice that relative URL (absolute URLs are always ignored, of course)? Well, by default, Laravel Mix and Webpack will find thing.png, copy it to your public/images folder, and then rewrite the url(). As such, your compiled CSS will be:

.example {
  background: url(/images/thing.png?d41d8cd98f00b204e9800998ecf8427e);
}

This, again, is a very cool feature of Webpack’s. However, it does have a tendency to confuse folks who don’t understand how Webpack and the css-loader plugin works. It’s possible that your folder structure is already just how you want it, and you’d prefer that Mix not modify those url()s. If that’s the case, we do offer an override:

mix.options({
    processCssUrls: false
});

With this addition to your webpack.mix.js file, we will no longer match url()s or copy assets to your public directory. As such, the compiled CSS will remain exactly as you typed it:

.example {
  background: url("../images/thing.png");
}

My Question

Should we disable CSS url() processing by default, for the next point release? Or, in other words, should CSS rewriting be opt-in, rather than opt-out?

I ask, because this is easily the most common point of confusion for folks switching from Laravel Elixir to Laravel Mix and Webpack.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:24 (3 by maintainers)

github_iconTop GitHub Comments

30reactions
kdumacommented, Feb 21, 2017

For me, opt-out. And the config line should be in mix config file, but commented.

5reactions
sergeifilippovcommented, Feb 21, 2017

Vote: Opt-out + docs + comments.

Since laravel-mix is a new direction with use of webpack as the core technology vs laravel-elixir and gulp, webpack defaults should be adhered to. This will help reduce confusion in the long run especially if people end up reading webpack documentation.

Newbies should read the documentation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Proper Way to Ask for Customer Feedback - Kayako
1. Know why you're asking for customers feedback · 2. Open a conversation · 3. Ask the right person the right questions. ·...
Read more >
How to Ask for & Actually Get Customer Feedback
Read these top strategies for obtaining customer feedback — and ... The most frequently used method to request customer feedback is email.
Read more >
Customer Feedback: Why It's Important + 7 Ways to Collect It
Customer feedback helps companies understand the experiences and needs of their community. Here are ways to collect your customers' ...
Read more >
How To Introduce Feedback Community to Customers
“Feature Requests for Admin Area”. Customer feedback board sample description. Add a short description to the board to guide your customers ...
Read more >
Asking feedback from a customer email sample - Acquire.io
One way to start asking for feedback from customers is via email. That email may be a direct request for feedback or it...
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