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.

Trying to integrate clean-css with node-sass on webpack

See original GitHub issue

We are working at clean-css-loader on a Webpack loader for Clean CSS. Right now we are having trouble with sourcemaps.

As it stands, we can’t get clean-css to play nicely with the sourcemap from sass-loader. I modified clean-css-loader to accept the sourcemap from the the previous loader in the chain (in this case, sass-loader) like this:

// Standard webpack loader header, receives file content and sourcemap from previous loader
module.exports = function(css, map) {
	//...

	cleanCssOpti.returnPromise = true;

	new CleanCSS(cleanCssOpti).minify(css, map)
        .then(function (minified) {
		// ...
		// pass content and sourcemap to next webpack loader
		callback(null, minified.styles, minified.sourceMap);
        })

However on the next loader after clean-css, the sourcemap’s only source is the main.scss file. But when omitting clean-css-loader from the loader chain, the correct sourcemap from sass-loader is received in the next loader.

This shouldn’t be too difficult to get around, I just don’t know what clean-css expects in a sourcemap and what does it do with it.

Thanks in advance.

CC: @jakubpawlowicz

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
stereokaicommented, Jul 11, 2017

Nice! That’s good news and looks like it was a straightforwards solution. I couldn’t get back on this, couldn’t fit it in my schedule. Thanks for updating!

0reactions
jakubpawlowiczcommented, Jul 9, 2017

4.2 will add integration with optimize-css-assets-webpack-plugin so I’m closing this now unless someone wants to work on it. If so I’ll reopen the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trying to integrate clean-css with node-sass on webpack #931
We are working at clean-css-loader on a Webpack loader for Clean CSS. Right now we are having trouble with sourcemaps.
Read more >
sass-loader - webpack - JS.ORG
Chain the sass-loader with the css-loader and the style-loader to immediately apply all styles to the DOM or the mini-css-extract-plugin to extract it...
Read more >
Setting up CSS and Sass with Webpack!! - DEV Community ‍ ‍
In this post, we will see how to set up both CSS and a CSS pre-processor like Sass with webpack one by one....
Read more >
React (Babel) and Sass webpack Tutorial: Extract CSS Into Its ...
Let's learn how to setup Babel, React, JSX, CSS, Sass and more with webpack !0:00 Intro1:27 Getting Started6:19 Loaders in webpack15:26 ...
Read more >
React, SCSS and Webpack - Medium
Let's start by adding sass-loader and node-sass packages. ... yarn clean; webpack --config config/webpack-prod-config.js $ rm -rf build/*
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