postcss-loader: [2.0.1] "Cannot create property 'prev' on boolean 'false'" (options.sourceMap)

Module build failed: TypeError: Cannot create property 'prev' on boolean 'false'
    at Promise.resolve.then.then (../node_modules/postcss-loader/lib/index.js:125:47)
    {
      loader: 'postcss-loader',
      options: {
        sourceMap: true,
        ...
      },
    },

These lines are the culprit: https://github.com/postcss/postcss-loader/blob/master/lib/index.js#L93 https://github.com/postcss/postcss-loader/blob/master/lib/index.js#L125

postcss@1.3.3 works fine

webpack@2.5.1 OSX 10.12.4 Node.js 7.10.0 postcss-loader@2.0.0

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 30 (12 by maintainers)

Most upvoted comments

I’m using 2.0.1 and still get the error

{
    test: /\.scss$/,
    use: [
        {
            loader: 'style-loader'
        },
        {
            loader: 'css-loader',
            options: {
                sourceMap: true
            }
        },
        {
            loader: 'postcss-loader',
            options: {
                plugins: [autoprefixer]
            }
        },
        {
            loader: 'sass-loader',
            options: {
                sourceMap: true,
                precision: 8
            }
        }
    ]
}

It works when I remove sourceMap from sass-loader

Issue also persists for me with version 2.0.1. Is it worth reopening this issue?

But map inside postcss.config.js isn’t supported atm 😃, this is debateable, but I left it on purpose, because it doesn’t fit into the way one enables sourcemaps ‘normally’ with webpack (consistency). Please use { sourceMap: true } in webpack.config.js

FYI I think this error occurs if the loader is set to pass sourceMaps:

use: [
  {
    loader: 'css-loader',
    options: {
      modules: true,
      minimize: true,
      importLoaders: 1,
      localIdentName: '[local]--[hash:base64:5]',
      sourceMap
    }
  },
  {
    loader: 'postcss-loader',
    options: {
      sourceMap
    }
  },
  {
    loader: 'sass-loader',
    options: {
      sourceMap
    }
  }
]

And the postcss.config.js also includes the map property:

map: process.env.NODE_ENV === 'development' ? 'inline' : false

@michael-ciniawsky Thanks, it works.