{"action":"closed","issue":{"url":"https://api.github.com/repos/yeoman/generator-webapp/issues/452","repository_url":"https://api.github.com/repos/yeoman/generator-webapp","labels_url":"https://api.github.com/repos/yeoman/generator-webapp/issues/452/labels{/name}","comments_url":"https://api.github.com/repos/yeoman/generator-webapp/issues/452/comments","events_url":"https://api.github.com/repos/yeoman/generator-webapp/issues/452/events","html_url":"https://github.com/yeoman/generator-webapp/issues/452","id":133468637,"number":452,"title":"[Suggestion] parameterize destination folder, 1 gulpfile, several projects","user":{"login":"jolugama","id":8806182,"avatar_url":"https://avatars.githubusercontent.com/u/8806182?v=3","gravatar_id":"","url":"https://api.github.com/users/jolugama","html_url":"https://github.com/jolugama","followers_url":"https://api.github.com/users/jolugama/followers","following_url":"https://api.github.com/users/jolugama/following{/other_user}","gists_url":"https://api.github.com/users/jolugama/gists{/gist_id}","starred_url":"https://api.github.com/users/jolugama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jolugama/subscriptions","organizations_url":"https://api.github.com/users/jolugama/orgs","repos_url":"https://api.github.com/users/jolugama/repos","events_url":"https://api.github.com/users/jolugama/events{/privacy}","received_events_url":"https://api.github.com/users/jolugama/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-02-13T20:07:07Z","updated_at":"2016-10-02T12:04:40Z","closed_at":"2016-10-02T12:04:40Z","body":"This is the gulpfile origin, modified with parameterize folders. In this case, it is a folder anotherAplication.\r\nTo implement projects using the same generator.\r\n\r\n```js\r\n// generated on 2016-02-04 using generator-gulp-webapp 1.1.1\r\nimport gulp from 'gulp';\r\nimport gulpLoadPlugins from 'gulp-load-plugins';\r\nimport browserSync from 'browser-sync';\r\nimport del from 'del';\r\nimport {stream as wiredep} from 'wiredep';\r\n\r\n//*** directorio parametrizable *** indicar dirección donde se aloja el proyecto\r\nconst app='../anotherAplication/app';\r\nconst appFolder='app';\r\nconst tmp='/../.tmp';\r\nconst tmpFoder='.tmp';\r\nconst scripts='/scripts';\r\nconst styles='/styles';\r\nconst images='/images';\r\nconst dist='/../dist';\r\nconst test='/../test';\r\nconst fonts='/fonts';\r\n\r\n//*** fin directorio parametrizable ***\r\n\r\n\r\nconst $ = gulpLoadPlugins();\r\nconst reload = browserSync.reload;\r\nconst appcripts='/'+app+scripts;\r\n\r\n//control de errores\r\nvar onError = function (err) {\r\n  console.log(err);\r\n};\r\n\r\ngulp.task('styles', () => {\r\n  return gulp.src(app+styles+'/**/*.scss')\r\n    .pipe($.plumber({errorHandler: onError}))\r\n    .pipe($.sourcemaps.init())\r\n    .pipe($.sass.sync({\r\n      outputStyle: 'expanded',\r\n      precision: 10,\r\n      includePaths: ['.']\r\n    }).on('error', $.sass.logError))\r\n    .pipe($.autoprefixer({browsers: ['last 2 versions']}))\r\n    .pipe($.sourcemaps.write())\r\n    .pipe(gulp.dest(app+tmp+styles))\r\n    .pipe(reload({stream: true}));\r\n});\r\n\r\ngulp.task('views', () => {\r\n  return gulp.src(app+'/*.jade')\r\n    .pipe($.jade({pretty: true}))\r\n    .pipe(gulp.dest(app+tmp))\r\n    .pipe(reload({stream: true}));\r\n});\r\n\r\ngulp.task('scripts', () => {\r\n  return gulp.src(app+scripts+'/**/*.js')\r\n    .pipe($.plumber({errorHandler: onError}))\r\n    .pipe($.sourcemaps.init())\r\n    .pipe($.babel({compact: false}))\r\n    .pipe($.sourcemaps.write('.'))\r\n    .pipe(gulp.dest(app+tmp+scripts))\r\n    .pipe(reload({stream: true}));\r\n});\r\n\r\nfunction lint(files, options) {\r\n  return () => {\r\n    return gulp.src(files)\r\n      .pipe(reload({stream: true, once: true}))\r\n      .pipe($.eslint(options))\r\n      .pipe($.eslint.format())\r\n      .pipe($.if(!browserSync.active, $.eslint.failAfterError()));\r\n  };\r\n}\r\nconst testLintOptions = {\r\n  env: {\r\n    mocha: true\r\n  }\r\n};\r\n\r\ngulp.task('lint', lint(app+scripts+'/**/*.js'));\r\ngulp.task('lint:test', lint(app+test+'/spec/**/*.js', testLintOptions));\r\n\r\ngulp.task('html', ['views', 'styles', 'scripts'], () => {\r\n  return gulp.src([app+tmp+'/*.html', app+'/*.html'])\r\n    .pipe($.useref({searchPath: [tmpFoder, appFolder, '.']}))\r\n    .pipe($.if('*.js', $.uglify()))\r\n    .pipe($.if('*.css', $.cssnano()))\r\n    .pipe($.if('*.html', $.minifyHtml({conditionals: true, loose: true})))\r\n    .pipe(gulp.dest(app+dist));\r\n});\r\n\r\ngulp.task('images', () => {\r\n  return gulp.src(app+images+'/**/*')\r\n    .pipe($.if($.if.isFile, $.cache($.imagemin({\r\n      progressive: true,\r\n      interlaced: true,\r\n      // don't remove IDs from SVGs, they are often used\r\n      // as hooks for embedding and styling\r\n      svgoPlugins: [{cleanupIDs: false}]\r\n    }))\r\n    .on('error', function (err) {\r\n      console.log(err);\r\n      this.end();\r\n    })))\r\n    .pipe(gulp.dest(app+dist+images));\r\n});\r\n\r\ngulp.task('fonts', () => {\r\n  return gulp.src(require('main-bower-files')({\r\n    filter: '**/*.{eot,svg,ttf,woff,woff2}'\r\n  }).concat(app+fonts+'/**/*'))\r\n    .pipe(gulp.dest(app+tmp+fonts))\r\n    .pipe(gulp.dest(app+dist+fonts));\r\n});\r\n\r\n//pasar a carpeta dist todo lo demas (iconos, robots.txt) excepto .jade y .html\r\ngulp.task('extras', () => {\r\n  return gulp.src([\r\n    app+'/*.*',\r\n    '!'+app+'/*.html',\r\n    '!'+app+'/*.jade'\r\n  ], {\r\n    dot: true\r\n  }).pipe(gulp.dest(app+dist));\r\n});\r\n\r\ngulp.task('clean', del.bind(null, [app+tmp, app+dist], {force:true}));\r\n\r\ngulp.task('serve', ['wiredep', 'styles', 'scripts', 'fonts'], () => {\r\n  browserSync({\r\n    notify: false,\r\n    port: 9000,\r\n    server: {\r\n      baseDir: [app+tmp, app],\r\n      routes: {\r\n        '/bower_components': 'bower_components'\r\n      }\r\n    }\r\n  });\r\n\r\n  gulp.watch([\r\n    app+'/*.html',\r\n    app+tmp+'/*.html',\r\n    app+scripts+'/**/*.js',\r\n    app+images+'/**/*',\r\n    app+tmp+'/fonts/**/*'\r\n  ]).on('change', reload);\r\n\r\n  gulp.watch(app+'/**/*.jade', ['views']);\r\n  gulp.watch(app +styles+'/**/*.scss', ['styles']);\r\n  gulp.watch(app+scripts+'/**/*.js', ['scripts']);\r\n  gulp.watch(app +'/fonts/**/*', ['fonts']);\r\n  gulp.watch('bower.json', ['wiredep', 'fonts']);\r\n});\r\n\r\ngulp.task('serve:dist', () => {\r\n  browserSync({\r\n    notify: false,\r\n    port: 9000,\r\n    server: {\r\n      baseDir: [app+dist]\r\n    }\r\n  });\r\n});\r\n\r\ngulp.task('serve:test', () => {\r\n  browserSync({\r\n    notify: false,\r\n    port: 9000,\r\n    ui: false,\r\n    server: {\r\n      baseDir: [app+test, app],\r\n      routes: {\r\n        '/bower_components': 'bower_components'\r\n      }\r\n    }\r\n  });\r\n\r\n\r\n  gulp.watch(app+test+'/spec/**/*.js').on('change', reload);\r\n  gulp.watch(app+test+'/spec/**/*.js', ['lint:test']);\r\n});\r\n\r\n// inject bower components\r\ngulp.task('wiredep', () => {\r\n  gulp.src(app +styles+'/**/*.scss')\r\n    .pipe(wiredep({\r\n      ignorePath: /^(\\.\\.\\/)+/,\r\n      cwd:app+'/../'\r\n    }))\r\n    .pipe(gulp.dest(app+styles));\r\n\r\n  gulp.src([app+'/*.html', app+'/*.jade'])\r\n    .pipe(wiredep({\r\n      ignorePath: /^(\\.\\.\\/)*\\.\\./,\r\n      cwd:app+'/../'\r\n    }))\r\n    .pipe(gulp.dest(app));\r\n});\r\n\r\ngulp.task('build', ['html', 'images', 'fonts', 'extras'], () => {\r\n  return gulp.src(app+dist+'/**/*').pipe($.size({title: 'build', gzip: true}));\r\n});\r\n\r\ngulp.task('default', ['clean'], () => {\r\n  gulp.start('build');\r\n});\r\n```"}}
{"actor":{"display_login":"silvenon"}}