2016-10-01 33 views
0

我有一个运行良好的Mac设置,但相同的安装程序似乎在Windows上失败。 babel-loader似乎没有做任何事情。这里是我的当前设置:与babel-loader的Webpackstream问题

Error code description

的package.json

"devDependencies": { 
    "babel-core": "^5.8.23", 
    "babel-loader": "^5.3.2", 
    "babel-preset-es2015": "^6.16.0", 
    "del": "^2.0.2", 
    "gulp": "github:gulpjs/gulp#4.0", 
    "gulp-bytediff": "^1.0.0", 
    "gulp-cached": "^1.1.0", 
    "gulp-changed": "^1.1.1", 
    "gulp-cli": "github:gulpjs/gulp-cli", 
    "gulp-connect": "^2.2.0", 
    "gulp-filesize": "0.0.6", 
    "gulp-html": "^0.4.3", 
    "gulp-iconfont": "^1.0.2", 
    "gulp-imagemin": "^2.2.1", 
    "gulp-jshint": "^1.11.2", 
    "gulp-load-plugins": "^0.10.0", 
    "gulp-minify-css": "~0.5.1", 
    "gulp-notify": "^2.2.0", 
    "gulp-plumber": "^1.0.1", 
    "gulp-rename": "^1.2.0", 
    "gulp-run": "^1.6.11", 
    "gulp-sass": "^2.1.0-beta", 
    "gulp-scss-lint": "^0.3.0", 
    "gulp-sourcemaps": "^1.5.0", 
    "gulp-swig": "^0.7.4", 
    "gulp-uglify": "^1.4.1", 
    "gulp-util": "^3.0.4", 
    "gulp-zip": "^3.0.2", 
    "jshint-stylish": "^2.0.1", 
    "lodash": "^3.10.1", 
    "merge-stream": "^0.1.7", 
    "minimist": "^1.2.0", 
    "nodemailer": "^1.5.0", 
    "require-dir": "^0.1.0", 
    "vinyl-named": "^1.1.0", 
    "vinyl-source-stream": "~1.0.0", 
    "webpack": "^1.12.1", 
    "webpack-stream": "^3.2.0" 
}, 
"dependencies": { 
    "babel-loader": "^5.4.2", 
    "fastclick": "^1.0.6", 
    "google-maps": "^3.2.1", 
    "jquery": "^2.1.4", 
    "js-cookie": "^2.1.0", 
    "js-marker-clusterer": "^1.0.0", 
    "lodash": "^3.10.1", 
    "select2": "^4.0.0" 
} 

(一饮而尽命令)的script.js

.pipe(webpackStream({ 
     watch: false, 
     plugins: [ 
     // Make jQuery globally availble in all scripts 
     new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', 'window.jQuery': 'jquery' }) 
     ], 
     module: { 
     loaders: [ 
      { 
      test: /.*\/scripts\/website\/.*\.jsx?$/, 
      exclude: 'node_modules', 
      loader: 'babel', 
      query: { 
       presets: ['es2015'], 
      }, 
      resolve: { 
       root: [ path.join(__dirname, 'node_modules/') ], 
       extensions: [ '', '.js', '.html' ], 
       modulesDirectories: [ 'node_modules' ], 
       alias: config.scripts.webpackAliases 
      } 
      } 
     ] 
     } 
    })) 

回答

0

你应该同时使用 “的WebPack” &“webpack-流“在你的”gulpfile.js“,所以需要他们或导入,如果你使用”babel.gulpfile.js“

const webpack = require('webpack'); 
const webpackStream = require('webpack-stream'); 

因此,在你大口的任务,你应该在你的管道使用的WebPack流,并通过两个参数是:

  1. 的WebPack配置(最好使用单独的文件)
  2. 的WebPack(这是较早的需要)

    .pipe(webpackStream(要求(” ./ webpack.config.js'),的WebPack))

顺便说一句在您的webpack配置中使用“babel-loader”而不是“babel”

Source