简体   繁体   English

您可能需要适当的加载器来处理此文件类型:Webpack 2

[英]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.

相关问题 Webpack 问题 - 您可能需要一个合适的加载器来处理此文件类型,目前没有配置加载器来处理此文件 - Webpack issue - You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file 带有webpack的Kalendar-vue:“您可能需要适当的加载器来处理此文件类型。”嗨 - Kalendar-vue with webpack: “You may need an appropriate loader to handle this file type.”Hi React.js:你可能需要一个合适的加载器来处理这种文件类型,目前没有配置加载器来处理这个文件 - React.js: You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file SVG Next Error 你可能需要一个合适的加载器来处理这个文件类型,目前没有加载器被配置来处理这个文件 - SVG Next Error You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file 您可能需要适当的加载器来处理此文件类型:react组件中的arrow函数 - You may need an appropriate loader to handle this file type: arrow function in react component “npm run build”模块解析错误“您可能需要适当的加载程序来处理此文件类型。” - "npm run build" module parse error "You may need an appropriate loader to handle this file type." 您可能需要一个额外的加载器来处理这些加载器的结果,r = ts(a[0]) - You may need an additional loader to handle the result of these loaders, r = ts(a[0]) “你可能需要一个额外的加载器来处理这些加载器的结果。” - "You may need an additional loader to handle the result of these loaders." 适当的加载器来处理这种文件类型。 /index.esm.js - Appropriate loader to handle this file type. /index.esm.js 模块解析失败:意外令牌。 您可能需要一个额外的加载器来处理这些加载器的结果 - Module parse failed: Unexpected token . You may need an additional loader to handle the result of these loaders
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM