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 warnings #278

Closed
egoist opened this issue Apr 27, 2018 · 20 comments
Closed

postcss-loader warnings #278

egoist opened this issue Apr 27, 2018 · 20 comments
Labels
type: enhancement Request to enhance an existing feature

Comments

@egoist
Copy link
Contributor

egoist commented Apr 27, 2018

vuepress/lib/build.js

Lines 99 to 107 in 2d6f02f

if (stats.hasErrors()) {
stats.toJson().errors.forEach(err => {
console.error(err)
})
reject(new Error(`Failed to compile with errors.`))
return
}
resolve(stats.toJson({ modules: false }))
})

VuePress didn't handle webpack warnings, but if you add following lines:

if (stats.hasWarnings()) {
  return reject(new Error(stats.toString()))
}

And if you run yarn build --debug in VuePress repo, there're actually postcss-loader warnings:

2018-04-27 10 04 08

Not sure if this is a vue-loader bug since I can only reproduce it in this repo. I've tried console.log this.sourceMap in vue-loader, seems it's always true even if I already set webpackConfig.devtool: false

Test against latest commit: 2d6f02f

@egoist egoist changed the title PostCSS warnings postcss-loader warnings Apr 27, 2018
@ulivz ulivz added the type: enhancement Request to enhance an existing feature label Apr 27, 2018
@meteorlxy
Copy link
Member

And another warning:

DeprecationWarning: Tapable.plugin is deprecated. Use new API on .hooks instead

@ulivz
Copy link
Member

ulivz commented Apr 27, 2018

Reproduced this problem, It works when set sourceMap to true. but what is strange is that no source map was generated. maybe need more investigation.

rule.use('postcss-loader').loader('postcss-loader').options(Object.assign({
        plugins: [require('autoprefixer')],
        sourceMap: true
      }, siteConfig.postcss))

@meteorlxy
Copy link
Member

meteorlxy commented Apr 27, 2018

  if (debug) {
    // config.devtool('source-map')
  } else if (!isProd) {
    config.devtool('cheap-module-eval-source-map')
  }

I tried to comment that line but failed.

Maybe the sourceMap should be set to !isProd || debug?

@ulivz
Copy link
Member

ulivz commented Apr 27, 2018

It should be:

  if (!isProd) {
    config.devtool('cheap-module-eval-source-map')
  } else if (debug) {
    config.devtool('source-map')
  }

@meteorlxy
Copy link
Member

Yes, but it will still cause the warning if we don't set the sourceMap to true in debug mode.

@ulivz
Copy link
Member

ulivz commented Apr 27, 2018

😅have you tested for that?

@egoist
Copy link
Contributor Author

egoist commented Apr 27, 2018

@meteorlxy hmm I was just using --debug to disable progress bar. The problem still exists without that flag.

The actual problem is vue-loader will return sourcemaps for style block in .vue file when devtool is set to false. That's what cause postcss-loader to throw warnings I guess.

@ulivz
Copy link
Member

ulivz commented Apr 27, 2018

Oh my egoist! I cannot repro it against 87e88f3 😂

@meteorlxy
Copy link
Member

meteorlxy commented Apr 27, 2018

Oh my ulivz, me neither!!

@ulivz
Copy link
Member

ulivz commented Apr 27, 2018

So amazing, what happened?

@meteorlxy
Copy link
Member

I have nooooooooo idea.

@meteorlxy
Copy link
Member

I even re-clone our repo again and cannot repro it....

@meteorlxy
Copy link
Member

emmm did you forget to add the hasWarning code.........

@ulivz
Copy link
Member

ulivz commented Apr 27, 2018

emmm this warning would be another issue 😅 It looks like one of our dependencies is outdated, or our dependencies' dependencies, or .....

@ulivz
Copy link
Member

ulivz commented Apr 27, 2018

Welcome to find it out, thanks!

@meteorlxy
Copy link
Member

meteorlxy commented Apr 27, 2018

@ulivz For me, after many times of git reset, I forgot to add:

if (stats.hasWarnings()) {
  return reject(new Error(stats.toString()))
}

After adding that again, I repro it successfully.....

(老哥咱俩是不是蠢到一块去了)

@ulivz
Copy link
Member

ulivz commented Apr 27, 2018

(老哥,咱俩是蠢到一块去了 😂)

@ulivz ulivz removed the need repro label Apr 27, 2018
@egoist
Copy link
Contributor Author

egoist commented Apr 28, 2018

@yyx990803 might be a bug in vue-loader?

@meteorlxy
Copy link
Member

meteorlxy commented Apr 30, 2018

Two things cause these warnings:

  1. stylus-loader default sourceMap options is { comment: false } but not false, so we have to disable it mannually in production mode. See related code of stylus-loader

  2. css-loader with modules: true may always have sourceMap before postcss-loader.

After I fix the stylus-loader's sourceMap problem, there are still two warnings about file docs/guide/using-vue.md and docs/zh/guide/using-vue.md, in which there is a css-module usage at the end of those two pages. So I realized the second point, but I'm not sure about the cause of that.

I will make a PR to fix this issue later.

@ulivz
Copy link
Member

ulivz commented May 10, 2018

Fixed at 34c7f99
Thanks to Evan at webpack-contrib/postcss-loader#361

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Request to enhance an existing feature
Projects
None yet
Development

No branches or pull requests

3 participants