Laravel-mix: .options({processCssUrl: false}) causes .sourceMaps() malfunctioning

Created on 12 Mar 2017  路  16Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 5.4.15
  • Node Version (node -v): 7.6.0
  • NPM Version (npm -v): 4.1.2
  • OS: 10.12.3
  • laravel-mix: 0.8.8

Description:

When use .sourceMaps() alone in my webpack.mix.js, the source map works fine for Sass compiling. With a fresh installation of Laravel, the generated css file is 1.61 MB. However, if options({processCssUrl: false}) is added, the css file is only 146KB, not minified, and no source map found by the browser. The source map part of the file is as this.

/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiIvY3NzL2FwcC5jc3MiLCJzb3VyY2VSb290IjoiIn0=*/

Steps To Reproduce:

  1. laravel new laravel_proj
  2. cd laravel_proj
  3. npm install
  4. open composer.json
  5. revise all bin/cross-env.js to dist/bin/cross-env.js (this is a fix found here for another error)
  6. revise "laravel-mix": "^0.8.1" to "laravel-mix": "^0.8.8", as suggested by @gudorian to eleminate error message on .options
  7. npm i
  8. open webpack.mix.js
  9. revise to
mix.sass('resources/assets/app/app.scss', 'public/css')
   .options({
      processCssUrls: false
   });
mix.sourceMaps()
  1. npm run dev
  2. result
            Asset      Size  Chunks                    Chunk Names
     /css/app.css    146 kB       0  [emitted]         /js/app
stale

Most helpful comment

I'm having the same issue, but for me it doesn't matter what I put processCssUrls to. I want it set to false, I tried setting it to "true", but it didn't make a difference.

I also tried using the master branch, just to see if I should pitch in I'm having the same issue, or if I should simply wait for next release.

After removing the node_modules directory and reinstalling with laravel-mix pointing to this git-repo, I still got an empty sass-sourcemap.

All 16 comments

I was able to re-produce this issue with Laravel mix v0.8.8.

This was fixed last week. We just haven't tagged it yet. Will do soon. Thx.

@JeffreyWay Fixed? What should I do to get the fix?

@DrewNeon
Wait for next release. If you can't then you can install from GitHub.
Checkout this link -
http://stackoverflow.com/questions/39732397/install-specific-branch-from-github-using-npm

npm can install a package directly from a Github repo

@ankurk91 Thanks for your help! I tried what you suggested, but failed. After running npm install git://github.com/JeffreyWay/laravel-mix.git#master --save',npm run dev` gave me the following error.

/.../node_modules/laravel-mix/setup/webpack.config.js:198
module.exports.module.rules = rules;
                            ^

TypeError: Cannot set property 'rules' of undefined
    at Object.<anonymous> (/Users/syslynk/Sites/laravel_new/node_modules/laravel-mix/setup/webpack.config.js:198:29)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at requireConfig (/Users/syslynk/Sites/laravel_new/node_modules/webpack/bin/convert-argv.js:96:18)
    at /Users/syslynk/Sites/laravel_new/node_modules/webpack/bin/convert-argv.js:109:17
    at Array.forEach (native)
    at module.exports (/Users/syslynk/Sites/laravel_new/node_modules/webpack/bin/convert-argv.js:107:15)
    at Object.<anonymous> (/Users/syslynk/Sites/laravel_new/node_modules/webpack/bin/webpack.js:153:40)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)

Guess I have to wait for the next release. BTW, how do I know there's a new release? The newest version under "Release" tab of this github repo is v0.8.2, but v0.8.8 is already available via npm install.

Don't use master. Just wait a day or so until we've tagged it.

@JeffreyWay I've upgraded to Laravel-Mix 0.9.2, but the issue #560 I reported remains the same. What did I miss?

Agree with @DrewNeon , it generates a single line of inline sourcemap.

/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiIvYnVpbGQvY3NzL2FwcC5taW4uOGRlN2VhMWM1Y2Y2YmJlOTk3MjQuY3NzIiwic291cmNlUm9vdCI6IiJ9*/

When i decode the string

{"version":3,"sources":[],"names":[],"mappings":"","file":"/build/css/app.min.8de7ea1c5cf6bbe99724.css","sourceRoot":""}

I'm having the same issue, but for me it doesn't matter what I put processCssUrls to. I want it set to false, I tried setting it to "true", but it didn't make a difference.

I also tried using the master branch, just to see if I should pitch in I'm having the same issue, or if I should simply wait for next release.

After removing the node_modules directory and reinstalling with laravel-mix pointing to this git-repo, I still got an empty sass-sourcemap.

I'm experiencing very strange behavior on a fresh laravel installation (on two different machines, both running macOS Sierra): by default source maps are generated (when they shouldn't), but if I actually call mix.sourceMaps() it only generates a single line, same as @ankurk91.

@JeffreyWay As this issue is closed but not fixed in the latest 0.9.2 release, should I start a new thread addressing this same issue? Please advice!

Laravel mix v0.10.0
I have tried both .sass() and the new .standaloneSass() method .
.sass() method behavior remain same.
.standaloneSass() method does generate inline sourcemap.

I can be wrong but trouble with css-loader
if remove https://github.com/JeffreyWay/laravel-mix/blob/master/src/Preprocessors/Preprocessor.js#L72
sourcemap work perfectly but not work processCssUrls

laravel-mix: 0.10.0

@webmarkelov Exactly! I need processCssUrls: false to work alone with mix.sourceMaps(), which isn't fixed in 0.10.0 yet.

Fixed in #654

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RomainGoncalves picture RomainGoncalves  路  3Comments

amin101 picture amin101  路  3Comments

terion-name picture terion-name  路  3Comments

wendt88 picture wendt88  路  3Comments

nezaboravi picture nezaboravi  路  3Comments