{"action":"created","comment":{"url":"https://api.github.com/repos/gulpjs/gulp/pulls/comments/54805820","id":54805820,"diff_hunk":"@@ -24,66 +24,154 @@ This file is just a quick sample to give you a taste of what gulp does.\n \n ```js\n var gulp = require('gulp');\n+var rename = require('gulp-rename');\n+var less = require('gulp-less');\n+var cssmin = require('gulp-cssmin');\n var coffee = require('gulp-coffee');\n var concat = require('gulp-concat');\n var uglify = require('gulp-uglify');\n-var imagemin = require('gulp-imagemin');\n-var sourcemaps = require('gulp-sourcemaps');\n var del = require('del');\n \n var paths = {\n-  scripts: ['client/js/**/*.coffee', '!client/external/**/*.coffee'],\n-  images: 'client/img/**/*'\n+  styles: {\n+    src: 'src/styles/**/*.less',\n+    dest: 'assets/styles/'\n+  },\n+  scripts: {\n+    src: 'src/scripts/**/*.coffee',\n+    dest: 'assets/scripts/'\n+  }\n };\n \n-/* Register some tasks to expose to the cli */\n-gulp.task('build', gulp.series(\n-  clean,\n-  gulp.parallel(scripts, images)\n-));\n+/* Not all tasks need to use streams, a gulpfile is just another node program\n+ * and you can use all packages available on npm, but it must return either a\n+ * Promise, a Stream or take a callback and call it\n+ */\n+function clean() {\n+  // You can use multiple globbing patterns as you would with `gulp.src`,\n+  // for example if you are using del 2.0 or above, return its promise\n+  return del([ 'assets' ]);\n+}\n+\n+/* \n+ * Define our tasks using plain functions\n+ */\n+function styles() {\n+  return gulp.src(paths.styles.src)\n+    .pipe(less())\n+    .pipe(cssmin())\n+    // pass in options to the task\n+    .pipe(rename({\n+          basename: 'main',\n+          suffix: '.min'\n+        }))\n+    .pipe(gulp.dest(paths.styles.dest));\n+}\n+\n+function scripts() {\n+  return gulp.src(paths.scripts.src, { sourcemaps: true })\n+    .pipe(coffee())\n+    .pipe(uglify())\n+    .pipe(concat('main.min.js'))\n+    .pipe(gulp.dest(paths.scripts.dest));\n+}\n+\n+function watch() {\n+  gulp.watch(paths.scripts.src, scripts);\n+  gulp.watch(paths.styles.src, styles);\n+}\n+\n+/* \n+ * Register some tasks to expose to the cli\n+ */\n gulp.task(clean);\n gulp.task(watch);\n \n-// The default task (called when you run `gulp` from cli)\n-gulp.task('default', gulp.series('build'));\n+/* \n+ * Notice that you can specify if tasks can run in parallel or not\n+ * using `gulp.series` and `gulp.parallel`\n+ */\n+gulp.task('build', gulp.series(clean, gulp.parallel(styles, scripts)));\n+\n+/*\n+ * Expose default task that can be called by just running `gulp` from cli\n+ */\n+gulp.task('default', build);\n+```\n+\n+## Use last JavaScript version in your gulpfile\n+\n+Node already supports a lot of **ES2015**, to avoid compatibility problem we suggest to install Babel and rename your `gulpfile.js` as `gulpfile.babel.js`.\n+\n+```sh\n+npm install --save-dev babel-core -babel-preset-es2015\n+```\n+\n+Then create a **.babelrc** file with the preset configuration.\n \n+```js\n+{\n+  \"presets\": [ \"es2015\" ]\n+}\n+```\n \n-/* Define our tasks using plain functions */\n+And here's the same sample from above written in **ES2015**.\n+\n+```js\n+import gulp from 'gulp';\n+import rename from 'gulp-rename';\n+import less from 'gulp-less';\n+import cssmin from 'gulp-cssmin';\n+import coffee from 'gulp-coffee';\n+import concat from 'gulp-concat';\n+import uglify from 'gulp-uglify';\n+import del from 'del';\n+\n+const paths = {\n+  styles: {\n+    src: 'src/styles/**/*.less',\n+    dest: 'assets/styles/'\n+  },\n+  scripts: {\n+    src: 'src/scripts/**/*.coffee',\n+    dest: 'assets/scripts/'\n+  }\n+};\n \n-// Not all tasks need to use streams\n-// A gulpfile is just another node program and you can use all packages available on npm\n-// But it must return either a Promise or Stream or take a Callback and call it\n function clean() {\n-  // You can use multiple globbing patterns as you would with `gulp.src`\n-  // If you are using del 2.0 or above, return its promise\n-  return del(['build']);\n+  return del([ 'assets' ]);\n }\n \n-// Copy all static images\n-function images() {\n-  return gulp.src(paths.images)\n-    // Pass in options to the task\n-    .pipe(imagemin({optimizationLevel: 5}))\n-    .pipe(gulp.dest('build/img'));\n+function styles() {\n+  return gulp.src(paths.styles.src)\n+    .pipe(less())\n+    .pipe(cssmin())\n+    .pipe(rename({\n+          basename: 'main',\n+          suffix: '.min'\n+        }))\n+    .pipe(gulp.dest(paths.styles.dest));\n }\n \n-// Minify and copy all JavaScript (except vendor scripts)\n-// with sourcemaps all the way down\n function scripts() {\n-  return gulp.src(paths.scripts)\n-    .pipe(sourcemaps.init())\n-      .pipe(coffee())\n-      .pipe(uglify())\n-      .pipe(concat('all.min.js'))\n-    .pipe(sourcemaps.write())\n-    .pipe(gulp.dest('build/js'));\n+  return gulp.src(paths.scripts.src, { sourcemaps: true })\n+    .pipe(coffee())\n+    .pipe(uglify())\n+    .pipe(concat('main.min.js'))\n+    .pipe(gulp.dest(paths.scripts.dest));","path":"README.md","position":171,"original_position":171,"commit_id":"65e5675a72761136e0a1bc995a8ed78dcb410782","original_commit_id":"65e5675a72761136e0a1bc995a8ed78dcb410782","user":{"login":"travm","id":385662,"avatar_url":"https://avatars.githubusercontent.com/u/385662?v=3","gravatar_id":"","url":"https://api.github.com/users/travm","html_url":"https://github.com/travm","followers_url":"https://api.github.com/users/travm/followers","following_url":"https://api.github.com/users/travm/following{/other_user}","gists_url":"https://api.github.com/users/travm/gists{/gist_id}","starred_url":"https://api.github.com/users/travm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/travm/subscriptions","organizations_url":"https://api.github.com/users/travm/orgs","repos_url":"https://api.github.com/users/travm/repos","events_url":"https://api.github.com/users/travm/events{/privacy}","received_events_url":"https://api.github.com/users/travm/received_events","type":"User","site_admin":false},"body":"Yep, thats looks correct! :+1: ","created_at":"2016-03-02T22:44:43Z","updated_at":"2016-03-02T22:44:43Z","html_url":"https://github.com/gulpjs/gulp/pull/1550#discussion_r54805820","pull_request_url":"https://api.github.com/repos/gulpjs/gulp/pulls/1550","_links":{"self":{"href":"https://api.github.com/repos/gulpjs/gulp/pulls/comments/54805820"},"html":{"href":"https://github.com/gulpjs/gulp/pull/1550#discussion_r54805820"},"pull_request":{"href":"https://api.github.com/repos/gulpjs/gulp/pulls/1550"}}},"pull_request":{"url":"https://api.github.com/repos/gulpjs/gulp/pulls/1550","id":61460069,"html_url":"https://github.com/gulpjs/gulp/pull/1550","diff_url":"https://github.com/gulpjs/gulp/pull/1550.diff","patch_url":"https://github.com/gulpjs/gulp/pull/1550.patch","issue_url":"https://api.github.com/repos/gulpjs/gulp/issues/1550","number":1550,"state":"open","locked":false,"title":"Added new gulpfile sample to README file with ES2015 version","user":{"login":"jeremenichelli","id":3856481,"avatar_url":"https://avatars.githubusercontent.com/u/3856481?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremenichelli","html_url":"https://github.com/jeremenichelli","followers_url":"https://api.github.com/users/jeremenichelli/followers","following_url":"https://api.github.com/users/jeremenichelli/following{/other_user}","gists_url":"https://api.github.com/users/jeremenichelli/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremenichelli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremenichelli/subscriptions","organizations_url":"https://api.github.com/users/jeremenichelli/orgs","repos_url":"https://api.github.com/users/jeremenichelli/repos","events_url":"https://api.github.com/users/jeremenichelli/events{/privacy}","received_events_url":"https://api.github.com/users/jeremenichelli/received_events","type":"User","site_admin":false},"body":"I added a new gulpfile sample from gulp 4.0 branch, more simple for new developers, who may not know about sourcemaps or coffee script, in my opinion and a version of it using **ES2015** with side notes about Babel installation requirement. [ issue  #1550 ]\r\n\r\n_split view recommended_","created_at":"2016-03-02T20:16:18Z","updated_at":"2016-03-02T22:44:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"51b5d08a169bf88fd3fdfacf19b77a81886833b8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gulpjs/gulp/pulls/1550/commits","review_comments_url":"https://api.github.com/repos/gulpjs/gulp/pulls/1550/comments","review_comment_url":"https://api.github.com/repos/gulpjs/gulp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gulpjs/gulp/issues/1550/comments","statuses_url":"https://api.github.com/repos/gulpjs/gulp/statuses/65e5675a72761136e0a1bc995a8ed78dcb410782","head":{"label":"jeremenichelli:readme-sample-es6","ref":"readme-sample-es6","sha":"65e5675a72761136e0a1bc995a8ed78dcb410782","user":{"login":"jeremenichelli","id":3856481,"avatar_url":"https://avatars.githubusercontent.com/u/3856481?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremenichelli","html_url":"https://github.com/jeremenichelli","followers_url":"https://api.github.com/users/jeremenichelli/followers","following_url":"https://api.github.com/users/jeremenichelli/following{/other_user}","gists_url":"https://api.github.com/users/jeremenichelli/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremenichelli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremenichelli/subscriptions","organizations_url":"https://api.github.com/users/jeremenichelli/orgs","repos_url":"https://api.github.com/users/jeremenichelli/repos","events_url":"https://api.github.com/users/jeremenichelli/events{/privacy}","received_events_url":"https://api.github.com/users/jeremenichelli/received_events","type":"User","site_admin":false},"repo":{"id":52988977,"name":"gulp","full_name":"jeremenichelli/gulp","owner":{"login":"jeremenichelli","id":3856481,"avatar_url":"https://avatars.githubusercontent.com/u/3856481?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremenichelli","html_url":"https://github.com/jeremenichelli","followers_url":"https://api.github.com/users/jeremenichelli/followers","following_url":"https://api.github.com/users/jeremenichelli/following{/other_user}","gists_url":"https://api.github.com/users/jeremenichelli/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremenichelli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremenichelli/subscriptions","organizations_url":"https://api.github.com/users/jeremenichelli/orgs","repos_url":"https://api.github.com/users/jeremenichelli/repos","events_url":"https://api.github.com/users/jeremenichelli/events{/privacy}","received_events_url":"https://api.github.com/users/jeremenichelli/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jeremenichelli/gulp","description":"The streaming build system","fork":true,"url":"https://api.github.com/repos/jeremenichelli/gulp","forks_url":"https://api.github.com/repos/jeremenichelli/gulp/forks","keys_url":"https://api.github.com/repos/jeremenichelli/gulp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jeremenichelli/gulp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jeremenichelli/gulp/teams","hooks_url":"https://api.github.com/repos/jeremenichelli/gulp/hooks","issue_events_url":"https://api.github.com/repos/jeremenichelli/gulp/issues/events{/number}","events_url":"https://api.github.com/repos/jeremenichelli/gulp/events","assignees_url":"https://api.github.com/repos/jeremenichelli/gulp/assignees{/user}","branches_url":"https://api.github.com/repos/jeremenichelli/gulp/branches{/branch}","tags_url":"https://api.github.com/repos/jeremenichelli/gulp/tags","blobs_url":"https://api.github.com/repos/jeremenichelli/gulp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jeremenichelli/gulp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jeremenichelli/gulp/git/refs{/sha}","trees_url":"https://api.github.com/repos/jeremenichelli/gulp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jeremenichelli/gulp/statuses/{sha}","languages_url":"https://api.github.com/repos/jeremenichelli/gulp/languages","stargazers_url":"https://api.github.com/repos/jeremenichelli/gulp/stargazers","contributors_url":"https://api.github.com/repos/jeremenichelli/gulp/contributors","subscribers_url":"https://api.github.com/repos/jeremenichelli/gulp/subscribers","subscription_url":"https://api.github.com/repos/jeremenichelli/gulp/subscription","commits_url":"https://api.github.com/repos/jeremenichelli/gulp/commits{/sha}","git_commits_url":"https://api.github.com/repos/jeremenichelli/gulp/git/commits{/sha}","comments_url":"https://api.github.com/repos/jeremenichelli/gulp/comments{/number}","issue_comment_url":"https://api.github.com/repos/jeremenichelli/gulp/issues/comments{/number}","contents_url":"https://api.github.com/repos/jeremenichelli/gulp/contents/{+path}","compare_url":"https://api.github.com/repos/jeremenichelli/gulp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jeremenichelli/gulp/merges","archive_url":"https://api.github.com/repos/jeremenichelli/gulp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jeremenichelli/gulp/downloads","issues_url":"https://api.github.com/repos/jeremenichelli/gulp/issues{/number}","pulls_url":"https://api.github.com/repos/jeremenichelli/gulp/pulls{/number}","milestones_url":"https://api.github.com/repos/jeremenichelli/gulp/milestones{/number}","notifications_url":"https://api.github.com/repos/jeremenichelli/gulp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jeremenichelli/gulp/labels{/name}","releases_url":"https://api.github.com/repos/jeremenichelli/gulp/releases{/id}","deployments_url":"https://api.github.com/repos/jeremenichelli/gulp/deployments","created_at":"2016-03-02T19:11:28Z","updated_at":"2016-03-02T19:11:30Z","pushed_at":"2016-03-02T22:12:17Z","git_url":"git://github.com/jeremenichelli/gulp.git","ssh_url":"git@github.com:jeremenichelli/gulp.git","clone_url":"https://github.com/jeremenichelli/gulp.git","svn_url":"https://github.com/jeremenichelli/gulp","homepage":"http://gulpjs.com","size":701,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gulpjs:4.0","ref":"4.0","sha":"56e3e56a27b7920a081f7002d69d547c8fc91336","user":{"login":"gulpjs","id":6200624,"avatar_url":"https://avatars.githubusercontent.com/u/6200624?v=3","gravatar_id":"","url":"https://api.github.com/users/gulpjs","html_url":"https://github.com/gulpjs","followers_url":"https://api.github.com/users/gulpjs/followers","following_url":"https://api.github.com/users/gulpjs/following{/other_user}","gists_url":"https://api.github.com/users/gulpjs/gists{/gist_id}","starred_url":"https://api.github.com/users/gulpjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gulpjs/subscriptions","organizations_url":"https://api.github.com/users/gulpjs/orgs","repos_url":"https://api.github.com/users/gulpjs/repos","events_url":"https://api.github.com/users/gulpjs/events{/privacy}","received_events_url":"https://api.github.com/users/gulpjs/received_events","type":"Organization","site_admin":false},"repo":{"id":11167738,"name":"gulp","full_name":"gulpjs/gulp","owner":{"login":"gulpjs","id":6200624,"avatar_url":"https://avatars.githubusercontent.com/u/6200624?v=3","gravatar_id":"","url":"https://api.github.com/users/gulpjs","html_url":"https://github.com/gulpjs","followers_url":"https://api.github.com/users/gulpjs/followers","following_url":"https://api.github.com/users/gulpjs/following{/other_user}","gists_url":"https://api.github.com/users/gulpjs/gists{/gist_id}","starred_url":"https://api.github.com/users/gulpjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gulpjs/subscriptions","organizations_url":"https://api.github.com/users/gulpjs/orgs","repos_url":"https://api.github.com/users/gulpjs/repos","events_url":"https://api.github.com/users/gulpjs/events{/privacy}","received_events_url":"https://api.github.com/users/gulpjs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gulpjs/gulp","description":"The streaming build system","fork":false,"url":"https://api.github.com/repos/gulpjs/gulp","forks_url":"https://api.github.com/repos/gulpjs/gulp/forks","keys_url":"https://api.github.com/repos/gulpjs/gulp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gulpjs/gulp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gulpjs/gulp/teams","hooks_url":"https://api.github.com/repos/gulpjs/gulp/hooks","issue_events_url":"https://api.github.com/repos/gulpjs/gulp/issues/events{/number}","events_url":"https://api.github.com/repos/gulpjs/gulp/events","assignees_url":"https://api.github.com/repos/gulpjs/gulp/assignees{/user}","branches_url":"https://api.github.com/repos/gulpjs/gulp/branches{/branch}","tags_url":"https://api.github.com/repos/gulpjs/gulp/tags","blobs_url":"https://api.github.com/repos/gulpjs/gulp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gulpjs/gulp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gulpjs/gulp/git/refs{/sha}","trees_url":"https://api.github.com/repos/gulpjs/gulp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gulpjs/gulp/statuses/{sha}","languages_url":"https://api.github.com/repos/gulpjs/gulp/languages","stargazers_url":"https://api.github.com/repos/gulpjs/gulp/stargazers","contributors_url":"https://api.github.com/repos/gulpjs/gulp/contributors","subscribers_url":"https://api.github.com/repos/gulpjs/gulp/subscribers","subscription_url":"https://api.github.com/repos/gulpjs/gulp/subscription","commits_url":"https://api.github.com/repos/gulpjs/gulp/commits{/sha}","git_commits_url":"https://api.github.com/repos/gulpjs/gulp/git/commits{/sha}","comments_url":"https://api.github.com/repos/gulpjs/gulp/comments{/number}","issue_comment_url":"https://api.github.com/repos/gulpjs/gulp/issues/comments{/number}","contents_url":"https://api.github.com/repos/gulpjs/gulp/contents/{+path}","compare_url":"https://api.github.com/repos/gulpjs/gulp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gulpjs/gulp/merges","archive_url":"https://api.github.com/repos/gulpjs/gulp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gulpjs/gulp/downloads","issues_url":"https://api.github.com/repos/gulpjs/gulp/issues{/number}","pulls_url":"https://api.github.com/repos/gulpjs/gulp/pulls{/number}","milestones_url":"https://api.github.com/repos/gulpjs/gulp/milestones{/number}","notifications_url":"https://api.github.com/repos/gulpjs/gulp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gulpjs/gulp/labels{/name}","releases_url":"https://api.github.com/repos/gulpjs/gulp/releases{/id}","deployments_url":"https://api.github.com/repos/gulpjs/gulp/deployments","created_at":"2013-07-04T05:26:06Z","updated_at":"2016-03-02T22:35:57Z","pushed_at":"2016-03-02T22:12:20Z","git_url":"git://github.com/gulpjs/gulp.git","ssh_url":"git@github.com:gulpjs/gulp.git","clone_url":"https://github.com/gulpjs/gulp.git","svn_url":"https://github.com/gulpjs/gulp","homepage":"http://gulpjs.com","size":1581,"stargazers_count":19612,"watchers_count":19612,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2331,"mirror_url":null,"open_issues_count":45,"forks":2331,"open_issues":45,"watchers":19612,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gulpjs/gulp/pulls/1550"},"html":{"href":"https://github.com/gulpjs/gulp/pull/1550"},"issue":{"href":"https://api.github.com/repos/gulpjs/gulp/issues/1550"},"comments":{"href":"https://api.github.com/repos/gulpjs/gulp/issues/1550/comments"},"review_comments":{"href":"https://api.github.com/repos/gulpjs/gulp/pulls/1550/comments"},"review_comment":{"href":"https://api.github.com/repos/gulpjs/gulp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gulpjs/gulp/pulls/1550/commits"},"statuses":{"href":"https://api.github.com/repos/gulpjs/gulp/statuses/65e5675a72761136e0a1bc995a8ed78dcb410782"}}}}