yibn2008 / fast-sass-loader

High performance sass loader for webpack
250 stars 38 forks source link

Passing outputStyle to sass.render #53

Closed bd041556 closed 5 years ago

bd041556 commented 5 years ago

We have successfully replaced sass-loader with fast-sass-loader, and are seeing very nice performance improvements. However, our output files are substantially larger. We have traced that to the fact that our rule for sass-loader sets use.options.outputStyle to "compressed"in our webpack configuration file, and we have many comments in our .scss files which outputStyle "compressed" eliminates.

Currently, I don't see a way to pass an outputStyle through fast-sass-loader to node-sass, so we experimented by hacking index.js to do that:

  try {
    let result = yield new Promise((resolve, reject) => {
      sass.render({
        indentedSyntax: entry.endsWith('.sass'),
        outputStyle: 'compressed',
        file: entry,
        data: merged
      }, (err, result) => {
        if (err) {
          reject(err)
        } else {
          resolve(result)
        }
      })
    })

and that worked for us. Can outputStyle be added to the fast-sass-loader options? We can work up a PR if you would like.

Thanks, Barry Bentley

yibn2008 commented 5 years ago

It's OK for me, PR will be welcome :-)

bd041556 commented 5 years ago

A PR has been created (Add output style to options). The source code changes are very simple. The README has been updated, and a test case (pass-output-style) has been created.

Thanks, Barry

yibn2008 commented 5 years ago

+fast-sass-loader@1.5.0