Webpack cannot load css solution

PHPz
Release: 2017-04-23 11:36:28
Original
2003 people have browsed it

Why can't webpack load css? The following is the error code for webpack loading css. I encountered it myself. I hope it will be helpful to everyone!

This app is written in react.

The loader setting of webpack is like this

module:{
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader:  'babel',
      },
      
      { 
        test: '/\.css$/', 
        loaders: ['style', 'css'],
        include: __dirname,
      },
    ],
  },
Copy after login

Also installed css-loader, style-loader

But when loading css,import './stylesheets/ all.css';
will report an error:

./app/stylesheets/all.css
Module parse failed: D:\FrontEnd\mzFM-web\app\stylesheets\all.css Unexpected token (1:11)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:11)
Copy after login

webpack cannot load css. Reasons and solutions:

原来test:'/\.css$/'这里写错了。
应该是test:/\.css$/ 不带''
Copy after login

Recommended CSS courses: php Chinese website CSS Video online tutorial

The above is the detailed content of Webpack cannot load css solution. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!