原文地址: 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:FrontEndmzFM-webappstylesheetsall.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$/ 不带''