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

[2.0.5] Explicit false not working (options.sourceMap) #250

Closed
leebenson opened this issue Jun 6, 2017 · 3 comments
Closed

[2.0.5] Explicit false not working (options.sourceMap) #250

leebenson opened this issue Jun 6, 2017 · 3 comments

Comments

@leebenson
Copy link

leebenson commented Jun 6, 2017

I have a function that dynamically sets whether sourceMaps should be included (amongst other options):

getExtractCSSLoaders(extractCSS, sourceMap = false) {
  return (function* loadCss() {
    for (const loader of css.loaders) {
      // Iterate over CSS/SASS/LESS and yield local and global mod configs
      for (const mod of css.getModuleRegExp(loader.ext)) {
        yield {
          test: new RegExp(mod[0]),
          loader: extractCSS.extract({
            use: [
              {
                loader: 'css-loader',
                query: Object.assign({}, css.loaderDefaults, {
                  sourceMap,
                }, mod[1]),
              },
              // 'postcss-loader',
              {
                loader: 'postcss-loader',
                options: {
                  sourceMap: false,
                },
              },
              ...loader.use,
            ],
            fallback: 'style-loader',
          }),
        };
      }
    }
  }());
},

Explicitly setting sourceMap: false seems to kill/bypass postcss:

// Explicitly setting `sourceMap` to the default `false` kills it...
{
  loader: 'postcss-loader',
  options: {
    sourceMap: false,
  },
},

Setting it to true works fine:

{
  loader: 'postcss-loader',
  options: {
    sourceMap: false,
  },
},

And ignoring the option is also fine:

{
  loader: 'postcss-loader',
},

A temporary workaround is to do a slightly uglier:

{
  // ...
  sourceMap ? {
    loader: 'postcss-loader',
    options: {
      sourceMap: true,
    },
  } : 'postcss-loader',
  // ...
}
@michael-ciniawsky
Copy link
Member

Yep, it's a know issue with the current config algo using !sourceMap internally, I try to fix it as soon as possible, but please omit it for now

@michael-ciniawsky michael-ciniawsky changed the title Explicit { sourceMap: false } not working [2.0.5] Explicit false not working (options.sourceMap) Jun 6, 2017
@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Jun 14, 2017

Fixed && Released in 2.0.6 please test and verify :) Reopen if still regressions

@michael-ciniawsky michael-ciniawsky modified the milestone: 2.0.7 Jun 14, 2017
leebenson added a commit to reactql/kit that referenced this issue Jun 15, 2017
1.8.1 - 2017-06-15
------------------------------------------------

## Webpack
* Improves sourceMap handling in `postcss-loader` per the fix at
webpack-contrib/postcss-loader#250

## NPM:
* Bumps packages:
"postcss-loader": "^2.0.6"
@leebenson
Copy link
Author

Works great, thanks @michael-ciniawsky !

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

No branches or pull requests

2 participants