小编Web*_*v T的帖子

使用npm作为构建工具连接文件

我最近发现我可以使用npm作为任务运行器而不是gulp或grunt,到目前为止一切都很棒(lint,stylus,jade,uglify,watch ......等)但是连接部分,我似乎无法实现.gulp就像是:

gulp.task('scripts', function() {
  return gulp.src('www/js/**/*.js')
    .pipe(concat('all.js'))
    .pipe(gulp.dest('www/dist'))
    .pipe(rename('all.min.js'))
    .pipe(uglify())
    .pipe(gulp.dest('www/dist'));
});
Run Code Online (Sandbox Code Playgroud)

有没有办法用npm做到这一点?

更清楚的是,我的目标是做这样的事情:

// package.json

{
  "name": "f_todo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "concat": "^1.0.0",
    "rerun-script": "^0.6.0",
    "stylus": "^0.53.0"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "stylus": "stylus ss --compress --out lib/stylesheets",
    "concat": "concat dependency code would be here",
    "dev": "rerun-script"
  },
  "watches": {
    "stylus": "ss/**"
  }
}
Run Code Online (Sandbox Code Playgroud)

javascript concatenation node.js npm

16
推荐指数
2
解决办法
1万
查看次数

标签 统计

concatenation ×1

javascript ×1

node.js ×1

npm ×1