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, }, ], },
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)
webpack cannot load css. Reasons and solutions:
原来test:'/\.css$/'这里写错了。 应该是test:/\.css$/ 不带''
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!