webpack-contrib / postcss-loader

PostCSS loader for webpack
MIT License
2.86k stars 211 forks source link

[2.0.5] Warnings about missing sourcemap when they are enabled (`options.sourceMap`) #248

Closed danyim closed 7 years ago

danyim commented 7 years ago

I'm seeing these warnings:

 ⚠️  PostCSS Loader

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

when my Webpack config explicitly sets the option to true:

      {
        test: /\.(scss|sass)$/,
        loader: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: [
            {
              loader: 'css-loader',
              options: {
                importLoaders: 2,
                sourceMap: true,
                modules: CSSModules,
                context: path.join(process.cwd(), './src'),
                localIdentName: isDev ? '[name]__[local].[hash:base64:5]' : '[hash:base64:5]',
                minimize: !isDev
              }
            },
            {
              loader: 'postcss-loader',
              options: {
                sourceMap: true
              }
            },
            {
              loader: 'sass-loader',
              options: {
                outputStyle: 'expanded',
                sourceMap: true,
                sourceMapContents: !isDev
              }
            }
          ]
        })
      },

Is there something I am misconfiguring? Or is this a bug? Also, "enterily" is typoed in the warning text.

yoyo837 commented 7 years ago

(Emitted value instead of an instance of error) the same, when i use postcss-loader vue-cli@2+ (.scss or other,not .vue)

yoyo837 commented 7 years ago

@danyim look at this https://github.com/postcss/postcss-loader/commit/159b66a

I switch to a low version @1.3.3

michael-ciniawsky commented 7 years ago

@danyim The typo should be fixed on master already, thx 😛 . Can you try without sourceMapContents: !isDev in sass-loader options? I will test it in a few minutes

michael-ciniawsky commented 7 years ago

@danyim I can't reproduce this in a small local test, could you please setup a small repo for debugging ?

michael-ciniawsky commented 7 years ago

Feel free to reopen if still regressions and please provide a small test repo, since I couldn't reproduce this myself

Janaka-Steph commented 7 years ago

Hello,

Postcss-loader: 2.0.6 Webpack: 2

I still have the warning "Previous source map found, but options.sourceMap isn't set." Here is part of my webpack.config.js :

module: {
    rules: [
      {
        test: /\.css$/,
        use: ['style-loader', 'css-loader']
      },
      {
        test: /\.scss$/,
        use: [
          'style-loader',
          'css-loader?module&importLoaders=1&localIdentName=[local]_[hash:base64:5]',
          'postcss-loader',
          'sass-loader?sourceMap'
        ]
      },
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
        query: {
          plugins: [
            //'transform-react-jsx',
            [
              'react-css-modules',
              {
                "generateScopedName": "[local]_[hash:base64:5]",
                "filetypes": {
                  ".scss": "postcss-scss"
                },
                "webpackHotModuleReloading": true
              }
            ]
          ]
        },
      }
}

Thank you for your help

michael-ciniawsky commented 7 years ago

@Janaka-Steph sass-loader (generates map) => postcss-loader (gets prev map from sass-loader, but doesn't update it, without ?sourceMap) => ⚠️

+ 'postcss-loader?sourceMap',
  'sass-loader?sourceMap'
matthopson commented 7 years ago

@Janaka-Steph I got around this by adding sourceMap: true to my postscss-loader config - so in your case, adding ?sourceMap to postcss-loader may help.

matthopson commented 7 years ago

Dah! @michael-ciniawsky wins the day! 🌮 🌮 for you.

Janaka-Steph commented 7 years ago

No it doesn't work for me :-( I tried what you said, I tried sourceMap everywhere, nowhere, in postcss.config, true, false. Nothing works. I don't know what to do

matthopson commented 7 years ago

@Janaka-Steph Here's exactly what I changed in my config to get rid of the warning.

{
      test: /\.scss$/,
      use: [
        'style-loader',
        cssModulesLoader,
        {
          loader: 'postcss-loader',
          options: {
            ident: 'postcss',
            sourceMap: true, // <-------- Added this line
            plugins: () => postcssConfig
          }
        },
        'sass-loader?sourceMap'
}
Janaka-Steph commented 7 years ago

Nope :-/ I print the error, maybe you understand something at this.

client?cd17:43 ./~/css-loader!./~/postcss-loader/lib!./~/resolve-url-loader!./~/sass-loader/lib/loader.js?sourceMap!./~/bootstrap-loader/lib/bootstrap.styles.loader.js?{"bootstrapVersion":4,"preBootstrapCustomizations":"/Users/steph/Desktop/PRO/Projects/dao1901_NewDawn/ui/assets/theme/pre-customizations.scss","bootstrapCustomizations":"/Users/steph/Desktop/PRO/Projects/dao1901_NewDawn/ui/assets/theme/customizations.scss","appStyles":"/Users/steph/Desktop/PRO/Projects/dao1901_NewDawn/ui/assets/theme/app.scss","extractStyles":false,"styleLoaders":["style-loader","css-loader","postcss-loader","sass-loader"],"styles":["mixins","normalize","print","reboot","type","images","code","grid","tables","forms","buttons","transitions","dropdown","button-group","input-group","custom-forms","nav","navbar","card","breadcrumb","pagination","jumbotron","alert","progress","media","list-group","responsive-embed","close","badge","modal","tooltip","popover","carousel","utilities"],"scripts":["alert","button","carousel","collapse","dropdown","modal","popover","scrollspy","tab","tooltip","util"],"configFilePath":"/Users/steph/Desktop/PRO/Projects/dao1901_NewDawn/.bootstraprc","bootstrapPath":"/Users/steph/Desktop/PRO/Projects/dao1901_NewDawn/~/bootstrap","bootstrapRelPath":"../bootstrap"}!./~/bootstrap-loader/no-op.js
(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.

 @ ./~/style-loader!./~/css-loader!./~/postcss-loader/lib!./~/resolve-url-loader!./~/sass-loader/lib/loader.js?sourceMap!./~/bootstrap-loader/lib/bootstrap.styles.loader.js?{"bootstrapVersion":4,"preBootstrapCustomizations":"/Users/steph/Desktop/PRO/Projects/dao1901_NewDawn/ui/assets/theme/pre-customizations.scss","bootstrapCustomizations":"/Users/steph/Desktop/PRO/Projects/dao1901_NewDawn/ui/assets/theme/customizations.scss","appStyles":"/Users/steph/Desktop/PRO/Projects/dao1901_NewDawn/ui/assets/theme/app.scss","extractStyles":false,"styleLoaders":["style-loader","css-loader","postcss-loader","sass-loader"],"styles":["mixins","normalize","print","reboot","type","images","code","grid","tables","forms","buttons","transitions","dropdown","button-group","input-group","custom-forms","nav","navbar","card","breadcrumb","pagination","jumbotron","alert","progress","media","list-group","responsive-embed","close","badge","modal","tooltip","popover","carousel","utilities"],"scripts":["alert","button","carousel","collapse","dropdown","modal","popover","scrollspy","tab","tooltip","util"],"configFilePath":"/Users/steph/Desktop/PRO/Projects/dao1901_NewDawn/.bootstraprc","bootstrapPath":"/Users/steph/Desktop/PRO/Projects/dao1901_NewDawn/~/bootstrap","bootstrapRelPath":"../bootstrap"}!./~/bootstrap-loader/no-op.js 4:14-1454 18:2-22:4 19:20-1460
 @ ./~/bootstrap-loader/lib/bootstrap.loader.js!./~/bootstrap-loader/no-op.js
 @ ./~/bootstrap-loader/loader.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server bootstrap-loader

Maybe it is due to bootstrap-loader ?

Here is the repo if you want to have a look: https://github.com/asseth/dao1901/tree/develop

yoyo837 commented 7 years ago

@michael-ciniawsky I created one, too. Here is the repo if you want to have a look: https://github.com/yoyo837/postcss-loader-248

adi518 commented 6 years ago

@matthopson That doesn't fix the problem properly. The a source map is needed for production, so by enabling it in development environment, you are increasing the build time, because it has to generate a Source map, which is really not needed, because while developing, your CSS is not minified.

So far, the only thing that fixes it for me is moving to postcss-loader@1.3.3.