2016-09-13 3 views
1

나는 yeoman 생성기를 만들었고 babel을 사용하기 시작했습니다. gulpefile.jsgulpfile.babel.js으로 변경하고 .babelrc 파일을 추가하십시오. gulpfile.js 외부 (프로젝트 gulpfile.babel.js 아님) 시작이 실패합니다.Yeoman이 술집에서 꿀꺽 꿀꺽 마심으로 실패합니다 (es2015)

프로젝트는 gulpfile.babel.js 작품으로 생성되었습니다. 그리고 실패한 꿀꺽 거리기 작업을 gulp pre-test으로 고정시킵니다.

이 내 보좌관 발전기 나무입니다 :

. 
├── README.md 
├── generators 
│   └── app 
│    ├── index.js 
│    └── templates 
│     └── my-awesome-site 
│      ├── Gemfile 
│      ├── README.md 
│      ├── _config.yml 
│      ├── _includes 
│      │   ├── footer.html 
│      │   ├── head.html 
│      │   └── header.html 
│      ├── _layouts 
│      │   ├── default.html 
│      │   ├── page.html 
│      │   └── post.html 
│      ├── _posts 
│      │   └── 2016-09-08-welcome-to-jekyll.markdown 
│      ├── about.md 
│      ├── feed.xml 
│      ├── gulpfile.babel.js 
│      ├── images 
│      │   └── touch 
│      │    ├── apple-touch-icon.png 
│      │    ├── chrome-touch-icon-192x192.png 
│      │    ├── icon-128x128.png 
│      │    └── ms-touch-icon-144x144-precomposed.png 
│      ├── index.html 
│      ├── package.json 
│      ├── robots.txt 
│      ├── scss 
│      │   ├── _base.scss 
│      │   ├── _layout.scss 
│      │   ├── _syntax-highlighting.scss 
│      │   └── main.scss 
│      └── travis 
├── gulpfile.js 
├── package.json 
└── test 
    └── app.js 

내가 실패 꿀꺽 작업 gulp pre-test를 정확하게 관리 :

gulp.task('pre-test', function() { 
    return gulp.src('generators/**/*.js') 
    .pipe(excludeGitignore()) 
    .pipe(istanbul({ 
     includeUntested: true 
    })) 
    .pipe(istanbul.hookRequire()); 
}); 

오류 메시지 :

[10:26:27] Using gulpfile ~/WebstormProjects/generator-jekyll-starter-kit/gulpfile.js 
[10:26:27] Starting 'pre-test'... 
Failed to parse file: /Users/nirgalon/WebstormProjects/generator-jekyll-starter-kit/generators/app/templates/my-awesome-site/gulpfile.babel.js 

events.js:160 
     throw er; // Unhandled 'error' event 
    ^
Error: Unable to parse /Users/nirgalon/WebstormProjects/generator-jekyll-starter-kit/generators/app/templates/my-awesome-site/gulpfile.babel.js 

Line 3: Unexpected token 

gulpfile.babel.js 라인 주변 3 :

'use strict'; 

import gulp from 'gulp'; 
import gulpLoadPlugins from 'gulp-load-plugins'; 
import runSequence from 'run-sequence'; 
import browserSync from 'browser-sync'; 

const $ = gulpLoadPlugins(); 

// Minify the HTML. 
gulp.task('minify-html',() => { 
    return gulp.src('_site/**/*.html') 
    .pipe($.htmlmin({ 
     removeComments: true, 
     collapseWhitespace: true, 
     collapseBooleanAttributes: true, 
     removeAttributeQuotes: true, 
     removeRedundantAttributes: true, 
     removeEmptyAttributes: true, 
     removeScriptTypeAttributes: true, 
     removeStyleLinkTypeAttributes: true, 
     removeOptionalTags: true 
    })) 
    .pipe(gulp.dest('_site')) 
}); 

나는 그걸 알아 내고, 성공하지 못한다. (나는 바벨과 관련이 있다고 생각하고 프로젝트 루트 package.json에 바벨을 설치하려고 시도했다.

답변

0

나는 대답을 찾을 수있다. gulp-eslint이고, ES2015 구문을 인식하지 못합니다. 아래 코드를 eslint에 추가하면 테스트가 잘 실행됩니다.

{ 
    ecmaFeatures: { 
    modules: true 
    }, 
    envs: [ 
    'browser', 'es6' 
    ], 
    parserOptions: { 
    sourceType: 'module' 
    } 
} 

전체 작업 :

gulp.task('static', function() { 
    return gulp.src('**/*.js') 
    .pipe(excludeGitignore()) 
    .pipe(eslint({ 
     ecmaFeatures: { 
     modules: true 
     }, 
     envs: [ 
     'browser', 'es6' 
     ], 
     parserOptions: { 
     sourceType: 'module' 
     } 
    })) 
    .pipe(eslint.format()) 
    .pipe(eslint.failAfterError()); 
}); 
0

gulpfile에서 es2015를 사용 중입니다. Node 버전이 지원하지 않을 가능성이 있습니까?

+0

나는 그것을 transpile하기 위해 바벨을 사용합니다. 노드와 관련이 없다고 생각합니다. 하지만 내 gulp.babel.js는 완벽하게 실행됩니다. – Nir