Webpack配置具有未知属性"preLoaders" [英] Webpack config has an unknown property 'preLoaders'

查看:393
本文介绍了Webpack配置具有未知属性"preLoaders"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从头开始学习Webpack.我已经学习了如何将JavaScript文件与require链接.我捆绑并缩小了我的js文件,并且正在听手表的更改.我正在设置加载程序以将我的sass文件转换为css.但是,当我尝试使用jshint-loader设置启动进程时,我遇到了问题.

I'm learning webpack from scratch. I've learned how to link javascript files with require. I'm bundling and minifying my js files and i'm listening for changes with watch. I'm setting up loaders to convert my sass files to css. But when I try to setup a linting process with jshint-loader, i'm running into issues.

    module: {
preLoaders: [
        {
            test: /\.js$/, // include .js files
            exclude: /node_modules/, // exclude any and all files in the node_modules folder
            loader: "jshint-loader"
        }
],

loaders: [
  {
    test: /\.scss$/,
    loader: 'style-loader!css-loader!sass-loader'
  },
  {
    test: /\.js$/,
    loader: 'babel-loader',
    exclude: /node_modules$/,
    query: {
      presets: ['es2015']
    }
  }
],

}

这是错误

无效的配置对象. Webpack已使用与API模式不匹配的配置对象进行了初始化. -configuration.module具有未知属性'preLoaders'.这些属性是有效的: 对象{exprContextCritical?,exprContextRecursive?,exprContextRegExp?,exprContextRequest ?、加载程序?,noParse ?、规则?,unknownContextCritical?,unknownContextRecursive?,unknownContextRegExp?,unknownContextRequest?,unsafeCache?,wapped wrapdContextCritical?,wrapedContextRecursive?,wrappedContextRegExp? } 影响普通模块的选项(NormalModuleFactory).

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration.module has an unknown property 'preLoaders'. These properties are valid: object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, loaders?, noParse?, rules?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp? } Options affecting the normal modules (NormalModuleFactory).

推荐答案

您显然正在尝试将示例用于webpack v1和webpack v2.直接来自 changelog :

You are apparently trying to use examples for webpack v1 with webpack v2. Straight from the changelog:

  module: {
-   preLoaders: [
+   rules: [
      {
        test: /\.js$/,
+       enforce: "pre",
        loader: "eslint-loader"
      }
    ]
  }

这篇关于Webpack配置具有未知属性"preLoaders"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆