原文地址: 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$/ 不帶''
