Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix prod css/sass sourcemaps (#1793) #2282

Merged
merged 4 commits into from Apr 2, 2020

Conversation

bentaber
Copy link
Contributor

@bentaber bentaber commented Nov 20, 2019

See Issue #1793

Sass sourcemaps fail to generate in production builds due to cssnano
combined with OptimizeCSSAssetsPlugin. Moving cssnano into
postcss-loader resolves issue.

More detail https://www.webfoobar.com/node/109

Note eval-source-maps still will not work at all for CSS, so
implementers must use Mix.sourceMaps(true, 'source-map') to allow
development builds to successfully generate sourcemaps.

Sass sourcemaps fail to generate in production builds due to cssnano
combined with OptimizeCSSAssetsPlugin.  Moving cssnano into
postcss-loader resolves issue.

More detail https://www.webfoobar.com/node/109

Note eval-source-maps still will not work at all for CSS, so
implementers must use `Mix.sourceMaps(true, 'source-map')` to allow
development builds to successfully generate sourcemaps.
@bentaber
Copy link
Contributor Author

Note all tests are passing when run locally. I notice last few commits do not pass appveyor ie: d432101

@JackWH
Copy link
Contributor

JackWH commented Dec 11, 2019

I can confirm this PR solved the problem for me.

In my case, I was compiling LESS, SCSS, and JS files with Mix. I was trying to compile app.js, app.less, error.less, landing.less, landing.js, and bootstrap.scss.

After dumping the Webpack configuration to the console before Mix ran, it was mis-calculating the entry points as follows:

entry:       {
  '/js/app':     [
    '/Users/Me/Sites/MySite/resources/js/app/app.js',
    '/Users/Me/Sites/MySite/resources/less/app/app.less',
    '/Users/Me/Sites/MySite/resources/less/app/error.less',
    '/Users/Me/Sites/MySite/resources/less/landing/landing.less',
    '/Users/Me/Sites/MySite/resources/scss/bootstrap.scss',
  ],
  '/js/landing': ['/Users/Me/Sites/MySite/resources/js/landing/landing.js'],
}

This was causing only two sourcemaps to be generated, for /js/app and /js/landing, but none corresponding to the CSS files.

Manually patching this PR causes the entry points to calculate correctly — one for each file — and 6 corresponding sourcemaps to be generated, rather than just 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants