我有一个gruntfile.js初始化webpack.config.js,反过来转换我的ES6代码 . 正确复制文件,但是转换失败并在控制台中发出以下错误:

ERROR in Loader /Users/dejimeji/Documents/Sites/incentive/incentive_web/node_modules/babel/index.js?{" presets":["es2015"]} didn't return a function @ multi main

gruntfile.js

module.exports = function(grunt) {

    var webpack = require("webpack");
    var webpackConfig = require("./webpack.config.js");

    grunt.initConfig({
        pkg: grunt.file.readJSON("package.json"),
        webpack: {
            options: webpackConfig,
            "build-dev": {
                devtool: "sourcemap",
                debug: true,
            }
        },
        uglify: {
            dist: {
                src: "assets/js/transpiled/app.es6.js",
                dest: "dist/assets/js/app.min.js"
            }
        },
        cssmin: {
            dist: {
                src: ["assets/css/custom/main.css"],
                dest: "dist/assets/css/main.min.css"
            }
        },
        sass: {
            options: {
                sourceMap: false,
                outputStyle: 'compressed'
            },
            dist: {
                files: {
                    'assets/css/custom/main.css': 'assets/sass/modules.scss'
                }
            }
        },
        watch: {
            js: {
                files: ['assets/**/*.js'],
                tasks: ['babel', 'uglify', 'clean'],
                options: {
                    livereload: true,
                }
            },
            css: {
                files: ['assets/css/**/*.scss', 'assets/css/**/*.css'],
                tasks: ['sass', 'cssmin'],
                options: {
                    livereload: true,
                }
            }
        },
        copy: {
            jquery: {
                files: [{
                    cwd: 'assets/frameworks/jquery/dist/',
                    src: ['jquery.min.js'],
                    dest: 'dist/assets/js/',
                    expand: true,
                    filter: 'isFile'
                }]
            },
            jqueryui: {
                files: [{
                    cwd: 'assets/frameworks/jqueryui/',
                    src: ['jquery-ui.min.js', 'images/'],
                    dest: 'dist/assets/js/',
                    expand: true,
                    filter: 'isFile'
                }]
            },
            bootstrapjs: {
                files: [{
                    cwd: 'assets/frameworks/bootstrap-4.0.0-alpha.4/dist/js/',
                    src: ['bootstrap.min.js'],
                    dest: 'dist/assets/js/',
                    expand: true,
                    filter: 'isFile'
                }]
            },
            bootstrapcss: {
                files: [{
                    cwd: 'assets/frameworks/bootstrap-4.0.0-alpha.4/dist/css/',
                    src: ['bootstrap.min.css', 'responsive.css'],
                    dest: 'dist/assets/css/',
                    expand: true,
                    filter: 'isFile'
                }]
            }
        },
        clean: {
            dist: {
                src: ['assets/js/transpiled']
            }
        }
    });

    grunt.loadNpmTasks("grunt-webpack");
    grunt.loadNpmTasks("grunt-babel");
    grunt.loadNpmTasks("grunt-sass");
    grunt.loadNpmTasks("grunt-contrib-concat");
    grunt.loadNpmTasks("grunt-contrib-connect");
    grunt.loadNpmTasks("grunt-contrib-cssmin");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks('grunt-contrib-copy');

    grunt.registerTask("default", ["babel", "uglify", "sass", "cssmin", "copy", "clean", "watch"]);
    grunt.registerTask("dist", ["babel", "uglify", "sass", "cssmin", "copy", "clean", "watch"]);
    grunt.registerTask("babes", ["babel"]);
    grunt.registerTask("tupac", ["webpack"]);
}

webpack.config.js

var path = require("path"),
    watchBabel = require("watch-babel"),
    srcJsDir = "./assets/js/custom/",
    srcDestJsDir = "./dist/assets/js/",
    options = { glob: "src/*.js" },
    watcher = watchBabel(srcJsDir, srcDestJsDir, options);

watcher.on("ready", function() {
    console.log("ready");
}).on("success", function(filepath) {
    console.log("Transpiled ", filepath);
}).on("failure", function(filepath, e) {
    console.log("Failed to transpile", filepath, "(Error: ", e);
}).on("delete", function(filepath) {
    console.log("Deleted file", filepath);
});

module.exports = {

    entry: [srcJsDir + "app.js"],
    output: {
        path: srcDestJsDir,
        filename: "app.tr.js"
    },
    watch: true,
    devServer: {
        inline: true,
        port: 8000
    },
    module: {
        loaders: [{
            test: /\.js$/,
            exclude: "/node_modules/",
            loader: ['babel'],
            query: {
                presets: ['es2015']
            }
        }]
    },
    resolveLoader: {
        root: path.join(__dirname, 'node_modules/')
    }
};

我怀疑它的设置是“预设:['es2015']”,但不知道我哪里出错了 . 任何帮助表示赞赏 .