未捕获的SyntaxError:意外的令牌导入

时间:2015-12-16 14:35:55

标签: gulp webpack babeljs

babel编译es6关于Uncaught SyntaxError:意外的令牌导入。 我使用webpack + gulp,但抛出意外的令牌导入。如何解决这个问题?

index.jsx

'use strict';
import React from 'react';

的package.json

 "devDependencies": {
    "babel-core": "^6.3.15",
    "babel-loader": "^6.2.0",
    "babel-preset-es2015": "^6.3.13",
    "babel-preset-react": "^6.3.13",
    "gulp": "^3.9.0",
    "gulp-webpack": "^1.5.0",
    "react": "^0.14.3",
    "react-tools": "^0.13.3",
    "vinyl-named": "^1.1.0",
    "webpack": "^1.12.9"
  }

gulpfile.js

 var gulp = require('gulp');
 var webpack = require('gulp-webpack');
 var named = require('vinyl-named');
 gulp.task('dev', function() {
    return gulp.src('app/scripts/index.jsx')
        .pipe(named())
        .pipe(webpack({
            watch : true,
            module: {
              loaders: [
                {
                    test: /\.jsx?$/,
                    exclude: /node_modules/,
                    loader: 'babel',
                    query: {
                        presets: ['react', 'es2015']
                    }
                }
              ]
            },
           output : {
               filename : '[name].jsx',
           },
           resolve: {
            alias: { localforage: 'localforage/dist/localforage.min' }
           }
        }))
        .pipe(gulp.dest('app/dist/'));
 });

0 个答案:

没有答案