原文地址: https://segmentfault.com/q/1010000005099261

 

这个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.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)

  

 

解决:

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

  

 

相关文章:

  • 2022-02-22
  • 2021-11-08
  • 2021-10-24
  • 2022-12-23
  • 2022-12-23
  • 2022-01-25
  • 2021-11-10
  • 2021-11-28
猜你喜欢
  • 2021-11-08
  • 2022-12-23
  • 2021-09-15
  • 2022-12-23
  • 2022-01-17
  • 2021-04-12
  • 2021-06-23
相关资源
相似解决方案