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

PostCSS Loader - SourceMap warning #1095

Closed
frankspin89 opened this issue Jul 16, 2017 · 17 comments
Closed

PostCSS Loader - SourceMap warning #1095

frankspin89 opened this issue Jul 16, 2017 · 17 comments

Comments

@frankspin89
Copy link

frankspin89 commented Jul 16, 2017

PostCSS loader keeps complaining about soureMap isn't set. Tried many different things, but nothing seems to work.

(Emitted value instead of an instance of Error)

 ⚠️  PostCSS Loader

Previous source map found, but options.sourceMap isn't set.
In this case the loader will discard the source map entirely for performance reasons.
See https://github.com/postcss/postcss-loader#sourcemap for more information.



 @ ./~/vue-style-loader!./~/css-loader?sourceMap!./~/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-36d0932b","scoped":false,"hasInlineConfig":true}!./~/postcss-loader/lib!./~/vue-loader/lib/selector.js?type=styles&index=0!./components/PageHeader.vue 4:14-335 13:3-1
7:5 14:22-343
 @ ./components/PageHeader.vue
 @ ./~/babel-loader/lib?{"presets":["vue-app"],"babelrc":false,"cacheDirectory":true}!./~/vue-loader/lib/selector.js?type=script&index=0!./pages/index.vue
 @ ./pages/index.vue
 @ ./.nuxt/router.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi webpack-hot-middleware/client?reload=true ./.nuxt/client.js

nuxt.config.js

build: {
    extend(config, ctx) {
      const cssLoader = config.module.rules.find((loader) => loader.test.toString() === '/\\.css$/')
      cssLoader.use.splice(2, 0, {
        loader: 'postcss-loader',
        options: {
          sourceMap: true
        }
      })
  }

postcss.config.js

module.exports = {
  plugins: {
    'postcss-import': {},
    'postcss-cssnext': { autoprefixer: true },
    'postcss-nested': {},
    'cssnano': {}
  },
  sourceMap: true
}
This question is available on Nuxt.js community (#c961)
@maicong
Copy link

maicong commented Jul 17, 2017

This is my solution, I hope this will help you.

nuxt.config.js

build: {
  postcss: [],
  extend (config) {
    const postcssLoader = {
      loader: 'postcss-loader?sourceMap'
    }
    config.module.rules.forEach(loader => {
      if (loader.test.toString() === '/\\.styl(us)?$/') {
        loader.use.splice(-1, 0, postcssLoader)
      }
      if (loader.loader === 'vue-loader') {
        loader.query.loaders.stylus.splice(-1, 0, postcssLoader)
        loader.query.loaders.styl.splice(-1, 0, postcssLoader)
      }
    })
  }
}

postcss.config.js

module.exports = {
  plugins: [
    require('postcss-cssnext')({
      warnForDuplicates: false,
      browsers: [
        'Chrome >= 28',
        'Firefox >= 28',
        'Edge >= 12',
        'Explorer >= 9',
        'Safari >= 5.1',
        'iOS >= 7',
        'Android >= 4',
        'ExplorerMobile >= 11',
        'ChromeAndroid >= 54',
        'FirefoxAndroid >= 50',
        'UCAndroid >= 11',
        'OperaMobile >= 12.1',
        'BlackBerry >= 10',
        'Samsung >= 4'
      ]
    }),
    require('postcss-import')(),
    require('cssnano')({
      preset: 'default'
    })
  ]
}

@frankspin89
Copy link
Author

hi @maicong. Sadly still getting the same error related to the sourceMap isn't set.

@frankspin89
Copy link
Author

frankspin89 commented Jul 20, 2017

@frankspin89
Copy link
Author

How would I disable sourceMap option on vue-style-loader and css-loader?

@yoyo837
Copy link

yoyo837 commented Aug 4, 2017

@frankspin89
If you do not use postcss new features, consider switching to a lower version postcss@1.3.3.
There is no better way before I know something new.
I have provided a demo to the Postcss author many days ago.

@pi0
Copy link
Member

pi0 commented Aug 14, 2017

The problems with postcss and its source map are going to almost resolved in next (rc5) release. (5d24294) Also a new build.cssSourceMap option is added so we can entirely disable ALL css related sourcemaps. (However not a good idea for dev mode)

@pi0
Copy link
Member

pi0 commented Aug 25, 2017

Now is available :)

@pi0 pi0 closed this as completed Aug 25, 2017
@cihadturhan
Copy link

Sorry @pi0 for resurrecting this issue but I still see same error on my console. It throws
Previous source map found, but options.sourceMap isn't set. for evey vue file with style in postcss. This drives me mad but I don't understand what's wrong. I'm using rc11.
Thanks

@cihadturhan
Copy link

Okay, I here is what's wrong: Don't include lang for postcss.
Change this

<style lang="postcss" scoped>
...
</style>

to

<style scoped>
...
</style>

@ghost
Copy link

ghost commented Sep 26, 2017

I have got the same problem and @cihadturhan solution works. However, now the syntax highlighting in VS Code (Vetur plugin) is wrong, because not including the lang tag defaults to CSS syntax highlighting. Is there another solution to fix this issue altogether?

@Sawtaytoes
Copy link

In my case, I was able to get rid of them by putting postcss-loader after stylus-loader. Is there a reason for that? Does it cause other issues?

@chanlito
Copy link

chanlito commented May 3, 2018

is anyone having this issue with the latest nuxt-edge? I'm getting Previous source map found, but options.sourceMap isn't set. warning I'm not even using postcss, @pi0 @clarkdo ?

@clarkdo
Copy link
Member

clarkdo commented May 8, 2018

Hi @chanlito, this is a closed isssue, could you please open a new one and follow the issue template ?

@clarkdo
Copy link
Member

clarkdo commented May 8, 2018

@chanlito
This warning has been fixed in webpack-contrib/postcss-loader#361
I'll upgrade post-loader now.

@ghost
Copy link

ghost commented Jun 5, 2018

Having the same minor issue as #1095 (comment) .

@clarkdo is this something i should log under the Vetur (@octref) project? Or is there something i can do to correctly get VS Code to highlight styles correctly as PostCSS and have it compile correctly with nuxt-edge?

@octref
Copy link

octref commented Jun 5, 2018

You can see the discussion here: vuejs/vetur#506 vuejs/vue-cli#1259

Vetur / VS Code uses textmate grammar which is not as flexible as build tools. It doesn't know your build config and don't know if you are using postcss.

Another issue is that we have CSS error-checking, but not PostCSS error-checking, as currently there is no PostCSS error checker available, so I have to turn off error-checking for PostCSS sections.

So, if you have a flexible build tool, you should make <style lang="postcss"> work for your build. It's really not that hard: vuejs/vue-cli@1037b9c

I like things being explicit and simple:

  • <style> receives css syntax highlight and errors
  • <style lang="postcss"> receives postcss syntax highlight and no errors for now
  • In the future when we have a PostCSS error checker, <style lang="postcss"> will receive PostCSS errors

@lock
Copy link

lock bot commented Nov 1, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 1, 2018
@danielroe danielroe added the 2.x label Jan 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests