[英]You may need an appropriate loader to handle this file type: Webpack 2
I have upgraded to Webpack 2 and am having problems with my loaders. 我已经升级到Webpack 2,而我的装载机有问题。 My project structure is as follows:
我的项目结构如下:
.
├── components
│ └── App.js
│
├── public
│ └──css
│ └──custom.css
└── src
└──sass
└──custom.scss
Inside App.js 内部App.js
import '../src/sass/custom.scss'
Inside webpack.config.js module.exports = 内部webpack.config.js module.exports =
{
test: /\.scss$/,
exclude: /node_modules/,
loaders: ExtractTextPlugin.extract({ fallbackLoader: 'style-loader', loader: 'sass-loader' }),
include: __dirname + '/src/sass'
}
Inside webpack.config.js plugins 内部webpack.config.js插件
//Add Bourbon dependency
new webpack.LoaderOptionsPlugin({
options: {
sassLoader: {
includePaths: require('bourbon').includePaths,
outputStyle: 'expanded',
},
context: '/src/sass',
}
})
My production script in package.json 我的生产脚本在package.json中
"production": "rm -rf public/index.html && NODE_ENV=production webpack -p && NODE_ENV=production node app.js"
But I get this error: 但是我得到这个错误:
**Child extract-text-webpack-plugin:
[0] ./~/sass-loader!./src/sass/custom.scss 283 bytes {0} [built] [failed] [1 error]**
ERROR in ./~/sass-loader!./src/sass/custom.scss
Module parse failed: /Users/user/apps/project/node_modules/sass-loader/index.js!/Users/user/apps/project/src/sass/custom.scss Unexpected token (1:5)
You may need an appropriate loader to handle this file type.
| body {
| background: white;
| }
I don't know why it cannot find my loaders. 我不知道为什么找不到我的装载机。 I have reinstalled everything (css, sass, style loaders) and even put them in both Dev and production dependencies sections.
我已经重新安装了所有内容(css,sass,样式加载器),甚至将它们放在“开发”和“生产依赖项”部分中。
There seems to be a lot of of issues with webpack 2 and poor documentation. webpack 2似乎有很多问题,而且文档不完善。 Is there anything I am missing here?
我在这里想念什么吗?
I believe that if you are using regexp test, then you don't need !style-loader!sass-loader! 我相信,如果您使用的是regexp测试,则不需要!style-loader!sass-loader! at your import.
在您的进口。 It may cause the problem as whole string is being parsed.
在解析整个字符串时,可能会导致问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.