webpack載入不了css解決辦法

來源:互聯網
上載者:User
webpack為什麼載入不了css?以下是webpack載入css報錯代碼,自己遇到的,希望對大家有協助!

這個app是用react寫的。

webpack的loader設定是這樣的

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

也安裝了css-loader, style-loader

但當載入css,import './stylesheets/all.css';
就會報錯:

./app/stylesheets/all.cssModule 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載入不了css解決原因和辦法:

原來test:'/\.css$/'這裡寫錯了。應該是test:/\.css$/ 不帶''

相關CSS課程推薦:php中文網CSS視頻線上教程

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.