Trying to integrate clean-css with node-sass on webpack
See original GitHub issueWe 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:
- Created 6 years ago
- Comments:6
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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!
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.