All Projects → JacksonGariety → Gulp Nodemon

JacksonGariety / Gulp Nodemon

gulp + nodemon + convenience

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Gulp Nodemon

Docker Compose Nodejs Examples
Finally some real world examples on getting started with Docker Compose and Nodejs
Stars: ✭ 944 (+77.78%)
Mutual labels:  gulp, nodemon
Redbot
REDbot is lint for HTTP.
Stars: ✭ 475 (-10.55%)
Mutual labels:  lint
Assemble
Community
Stars: ✭ 3,995 (+652.35%)
Mutual labels:  gulp
Fetool
大前端的瑞士军刀,只记录有用的。
Stars: ✭ 4,328 (+715.07%)
Mutual labels:  gulp
Magento2 Frontools
Set of front-end tools for Magento 2 based on Gulp.js
Stars: ✭ 416 (-21.66%)
Mutual labels:  gulp
Kickoff
🏀 A lightweight front-end framework for creating scalable, responsive sites. Version 8 has just been released!
Stars: ✭ 465 (-12.43%)
Mutual labels:  gulp
Pixel Bootstrap Ui Kit
Pixel UI - Free and open source Bootstrap 5 UI Kit without jQuery
Stars: ✭ 406 (-23.54%)
Mutual labels:  gulp
Long Haul
A minimal, type-focused Jekyll theme.
Stars: ✭ 524 (-1.32%)
Mutual labels:  gulp
Gulp Shell
A handy command line interface for gulp
Stars: ✭ 474 (-10.73%)
Mutual labels:  gulp
Vscode Markdownlint
Markdown linting and style checking for Visual Studio Code
Stars: ✭ 444 (-16.38%)
Mutual labels:  lint
Meantorrent
meanTorrent - MEAN.JS BitTorrent Private Tracker - Full-Stack JavaScript Using MongoDB, Express, AngularJS, and Node.js, A BitTorrent Private Tracker CMS with Multilingual, and IRC announce support, CloudFlare support. Demo at:
Stars: ✭ 438 (-17.51%)
Mutual labels:  gulp
Checkmake
experimental linter/analyzer for Makefiles
Stars: ✭ 420 (-20.9%)
Mutual labels:  lint
Purpleadmin Free Admin Template
Purple Admin is one of the most stylish Bootstrap admin dashboard you can get hands on. With its beautifully crafted captivating design and well-structured code.
Stars: ✭ 473 (-10.92%)
Mutual labels:  gulp
Video.github.io
🎬视频网站项目已实现功能: 首页导航栏,中部轮播图,以及电影列表的展现,底部导航链接 注册页面 视频播放页面 搜索页面 登录页面 用户管理页面 一键安装 电影抓取 等功能。基于NodeJS的Express框架开发的动态网站项目,下面也提供了本程序的相关演示站点。
Stars: ✭ 413 (-22.22%)
Mutual labels:  gulp
Gulp Responsive
gulp-responsive generates images at different sizes
Stars: ✭ 509 (-4.14%)
Mutual labels:  gulp
Lockfile Lint
Lint an npm or yarn lockfile to analyze and detect security issues
Stars: ✭ 411 (-22.6%)
Mutual labels:  lint
Made Mistakes Jekyll
Source for my website and blog (Jekyll + Gulp + Netlify)
Stars: ✭ 436 (-17.89%)
Mutual labels:  gulp
Neumorphism Ui Bootstrap
Neumorphism inspired UI Kit: web components, sections and pages in neumorphic style built with Bootstrap CSS Framework
Stars: ✭ 463 (-12.81%)
Mutual labels:  gulp
Gulp Angular Templatecache
Concatenates and registers AngularJS templates in the $templateCache.
Stars: ✭ 530 (-0.19%)
Mutual labels:  gulp
Gulp Pug
Gulp plugin for compiling Pug templates
Stars: ✭ 512 (-3.58%)
Mutual labels:  gulp

gulp-nodemon

gulp + nodemon + convenience

Install

$ npm install --save-dev gulp-nodemon

Usage

Gulp-nodemon is almost exactly like regular nodemon, but it's made for use with gulp tasks.

nodemon([options])

Gulp-nodemon takes an options object just like the original.

Example below will start server.js in development mode and watch for changes, as well as watch all .html and .js files in the directory.

gulp.task('start', function (done) {
  nodemon({
    script: 'server.js'
  , ext: 'js html'
  , env: { 'NODE_ENV': 'development' }
  , done: done
  })
})

Synchronous Build Tasks

NOTE: This feature requires Node v0.12 because of child_process.spawnSync.

Gulp-nodemon can synchronously perform build tasks on restart.

{ tasks: [Array || Function(changedFiles)] }

If you want to lint your code when you make changes that's easy to do with a simple event. But what if you need to wait while your project re-builds before you start it up again? This isn't possible with vanilla nodemon, and can be tedious to implement yourself, but it's easy with gulp-nodemon:

nodemon({
  script: 'index.js'
, tasks: ['browserify']
})

What if you want to decouple your build processes by language? Or even by file? Easy, just set the tasks option to a function. Gulp-nodemon will pass you the list of changed files and it'll let you return a list of tasks you want run.

NOTE: If you manually restart the server (rs) this function will receive a changedFiles === undefined so check it and return the tasks because it expects an array to be returned.

nodemon({
  script: './index.js'
, ext: 'js css'
, tasks: function (changedFiles) {
    var tasks = []
    if (!changedFiles) return tasks;
    changedFiles.forEach(function (file) {
      if (path.extname(file) === '.js' && !~tasks.indexOf('lint')) tasks.push('lint')
      if (path.extname(file) === '.css' && !~tasks.indexOf('cssmin')) tasks.push('cssmin')
    })
    return tasks
  }
})

Events

gulp-nodemon returns a stream just like any other NodeJS stream, except for the on method, which conveniently accepts gulp task names in addition to the typical function.

.on([event], [Array || Function])

  1. [event] is an event name as a string. See nodemon events.
  2. [tasks] An array of gulp task names or a function to execute.

.emit([event])

  1. event is an event name as a string. See nodemon events.

Examples

Basic Usage

The following example will run your code with nodemon, lint it when you make changes, and log a message when nodemon runs it again.

// Gulpfile.js
var gulp = require('gulp')
  , nodemon = require('gulp-nodemon')
  , jshint = require('gulp-jshint')

gulp.task('lint', function () {
  gulp.src('./**/*.js')
    .pipe(jshint())
})

gulp.task('develop', function (done) {
  var stream = nodemon({ script: 'server.js'
          , ext: 'html js'
          , ignore: ['ignored.js']
          , tasks: ['lint'] })
          , done: done

  stream
      .on('restart', function () {
        console.log('restarted!')
      })
      .on('crash', function() {
        console.error('Application has crashed!\n')
         stream.emit('restart', 10)  // restart the server in 10 seconds
      })
})

You can also plug an external version or fork of nodemon

gulp.task('pluggable', function() {
  nodemon({ nodemon: require('nodemon'),
            script: 'server.js'})
})

Bunyan Logger integration

The bunyan logger includes a bunyan script that beautifies JSON logging when piped to it. Here's how you can you can pipe your output to bunyan when using gulp-nodemon:

gulp.task('run', ['default', 'watch'], function(done) {
    var nodemon = require('gulp-nodemon'),
        spawn   = require('child_process').spawn,
        bunyan

    nodemon({
        script: paths.server,
        ext:    'js json',
        ignore: [
            'var/',
            'node_modules/'
        ],
        watch:    [paths.etc, paths.src],
        stdout:   false,
        readable: false,
        done: done
    })
    .on('readable', function() {

        // free memory
        bunyan && bunyan.kill()

        bunyan = spawn('./node_modules/bunyan/bin/bunyan', [
            '--output', 'short',
            '--color'
        ])

        bunyan.stdout.pipe(process.stdout)
        bunyan.stderr.pipe(process.stderr)

        this.stdout.pipe(bunyan.stdin)
        this.stderr.pipe(bunyan.stdin)
    });
})

Using gulp-nodemon with React, Browserify, Babel, ES2015, etc.

Gulp-nodemon is made to work with the "groovy" new tools like Babel, JSX, and other JavaScript compilers/bundlers/transpilers.

In gulp-nodemon land, you'll want one task for compilation that uses an on-disk cache (e.g. gulp-file-cache, gulp-cache-money) along with your bundler (e.g. gulp-babel, gulp-react, etc.). Then you'll put nodemon({}) in another task and pass the entire compile task in your config:

var gulp = require('gulp')
  , nodemon = require('gulp-nodemon')
  , babel = require('gulp-babel')
  , Cache = require('gulp-file-cache')

var cache = new Cache();

gulp.task('compile', function () {
  var stream = gulp.src('./src/**/*.js') // your ES2015 code
                   .pipe(cache.filter()) // remember files
                   .pipe(babel({ ... })) // compile new ones
                   .pipe(cache.cache()) // cache them
                   .pipe(gulp.dest('./dist')) // write them
  return stream // important for gulp-nodemon to wait for completion
})

gulp.task('watch', ['compile'], function (done) {
  var stream = nodemon({
                 script: 'dist/' // run ES5 code
               , watch: 'src' // watch ES2015 code
               , tasks: ['compile'] // compile synchronously onChange
               , done: done
               })

  return stream
})

The cache keeps your development flow moving quickly and the return stream line ensure that your tasks get run in order. If you want them to run async, just remove that line.

Using gulp-nodemon with browser-sync

Some people want to use browser-sync. That's totally fine, just start browser sync in the same task as nodemon({}) and use gulp-nodemon's .on('start', function () {}) to trigger browser-sync. Don't use the .on('restart') event because it will fire before your app is up and running.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].