search

Home  >  Q&A  >  body text

webpack problem css loader problem - Stack Overflow

I installed the css loader through npm install style-loader css-loader --save-dev.
This is a screenshot of webpack.config.js:

Screenshot of git error report:

Tutorial link: link description

I tried the above tutorial several times but still got an error.

phpcn_u1582phpcn_u15822768 days ago697

reply all(3)I'll reply

  • 代言

    代言2017-06-15 09:24:55

    That person said not to omit the -loader after babel. It should be a version problem. Webpack2 cannot omit it

    reply
    0
  • 某草草

    某草草2017-06-15 09:24:55

    const path = require('path')
    
    module:{
      rules:[
        {
          test: /\.css$/,
          loader: 'style-loader!css-loader'
        },
        {
          test: /\.js$/,
          loader: 'babel-loader',
          exclude: path.resolve(__dirname, 'node_modules'),
          query: {
              presets: ['es2015']
            }
        },
      ]  
    }

    reply
    0
  • 黄舟

    黄舟2017-06-15 09:24:55

    Sure enough, programmers still need to know a little bit about English, otherwise they will not be able to understand the error messages.
    The red error report is talking about the problem with the babel loader, not the css loader problem you mentioned.
    Tips that you need to specify "babel-loader" and cannot omit "-loader"

    reply
    0
  • Cancelreply