码迷,mamicode.com
首页 > 其他好文 > 详细

可以一行指令新建一个新的页面及路由

时间:2016-09-25 20:44:40      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:

//新 view
gulp.task("new_view",function(name,distName){
  return gulp.src(‘templates/page.handlebars‘)//取源文件
    .pipe(template({name: name?name:"new"}))//name参数是否有值
    .pipe(rename({
      basename:name
    }))
    .pipe(gulp.dest(‘jade/views‘));//在views文件夹输出
})
//新 service
gulp.task("new_service ",function(name,distName ){
  return gulp.src(‘templates/service .js‘)
    .pipe(template({name: distName ?distName :"new"}))
    .pipe(rename({
      basename:name
    }))
    .pipe(gulp.dest(‘js/‘+distName+‘/‘));//在distName 文件夹输出
})
//新 controller
gulp.task("new_controller ",function(name,distName ){
  return gulp.src(‘templates/controller .js‘)
    .pipe(template({name: name?name:"new"}))
    .pipe(rename({
      basename:name
    }))
    .pipe(gulp.dest(‘js/‘+distName+‘/‘));//在distName 文件夹输出
})
//gulp.task("new_less",function(name){
 // return gulp.src(‘templates/style.less‘)
 //   .pipe(template({name: name?name:"new"}))
 //   .pipe(rename({
 //     basename:name
 //   }))
//    .pipe(gulp.dest(‘src/less‘));
//})

gulp.task("inject_routes",function(name){
  return gulp.src("js/common/routes.config.js")
  .pipe(replace("//more", ‘ .state(getState(),{\nurl:,\ntitle:,\ntemplateUrl:helper.basepath(),\nresolve: helper.resolveFor( ),\nconf : { login : true, level : [1, 2, 3]},
})\n //more
‘))
 // .pipe(replace("//newRouter", ‘//newRouter\napp.use("/‘+name+‘", router_‘+name+‘);‘))
  .pipe(gulp.dest("js/common/routes.config.js "))
})

gulp.task(‘new‘,function (name,controller,distName) {
  if(router)
 //   return runsequence([‘new_view‘,"new_less","new_router","inject_app"]);
    return runsequence([‘new_view‘,"new_controller ","inject_routes "]);
  else
    return runsequence([‘new_view‘]);
//   return runsequence([‘new_view‘,"new_less"]);
})

  

可以一行指令新建一个新的页面及路由

标签:

原文地址:http://www.cnblogs.com/xd1024/p/5906668.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!