webpack - 无法使用 Babel loader 和 Webpack 解析 Babel 插件

标签 webpack babeljs gulp-babel

我有以下 Webpack 配置:

{
    resolveLoader: {
        root: path.join(__dirname, 'node_modules')
    },
    module: {
        loaders: [
            {
                test: /\.es6?$/,
                exclude: /node_modules/,
                loader: 'babel',
                query: {
                    sourceMap: true,
                    presets: [
                        'es2015'
                    ],
                    plugins: [
                        'transform-class-properties'
                    ]
                }
            }
        ]
    }
}

我的项目结构:

.
+-- deploy
|   +-- node_modules
|   +-- Gulpfile.js
+-- es6
|   +-- Source files

我得到的错误:

ERROR in ../es6/src.es6
Module build failed: ReferenceError: Unknown plugin "transform-class-properties" specified in "base" at 0, attempted to resolve relative to "[ABSOLUTE_PATH]/es6"

似乎由于某种原因,resolveLoader 不起作用。

尝试删除 transform-class-properties 插件,但对于 es2015 预设,我会收到相同的错误。

有什么建议吗?

最佳答案

在此处输入代码替换加载器 x 规则:

 module: {
       loaders: [
            {
           }
        ]
     }

关于webpack - 无法使用 Babel loader 和 Webpack 解析 Babel 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37032232/

相关文章:

webpack - 将 'browser'设置为 'target'后,Webpack将忽略 'electron-renderer'字段

javascript - React Native 中的 Flex header 布局

javascript - 在生产中使用 babel-node 可以吗

javascript - Gulp4 - 任务未完成并忘记发出异步完成信号

javascript - gulp-babel 和严格模式

html - Webpack 替换 Assets 以清除缓存

webpack - 在应用程序 HTML 中包含指向 webpack 入口点的直接链接?

javascript - Webpack 有条件导入 JavaScript 模块

javascript - 在 Webpack 中读取解析路径中的文件