Skip to content

Commit b4d4d0b

Browse files
committed
gulp task to auto re-start on file changes
1 parent b2cf214 commit b4d4d0b

File tree

2 files changed

+56
-35
lines changed

2 files changed

+56
-35
lines changed

gulpfile.babel.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import gulp from 'gulp';
22
import gulpLoadPlugins from 'gulp-load-plugins';
33
import path from 'path';
44
import del from 'del';
5+
import runSequence from 'run-sequence';
56

67
const plugins = gulpLoadPlugins();
78

@@ -31,4 +32,23 @@ gulp.task('babel', () => {
3132
}
3233
}))
3334
.pipe(gulp.dest('dist'));
35+
});
36+
37+
// Start server with restart on file changes
38+
gulp.task('nodemon', ['babel'], () => {
39+
plugins.nodemon({
40+
script: path.join('dist', 'index.js'),
41+
ext: 'js',
42+
ignore: ['node_modules/**/*.js', 'dist/**/*.js'],
43+
tasks: ['babel']
44+
});
45+
});
46+
47+
gulp.task('serve', ['clean'], () => {
48+
runSequence('nodemon');
49+
});
50+
51+
// clean and compile files, the default task
52+
gulp.task('default', ['clean'], () => {
53+
runSequence('babel');
3454
});

package.json

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
{
2-
"name": "express-es6-rest-api-starter",
3-
"version": "0.1.0",
4-
"description": "Starter project for an ES6 RESTful Express API",
5-
"main": "index.js",
6-
"private": false,
7-
"scripts": {
8-
"start": "gulp babel && node dist/index.js",
9-
"test": "echo \"Error: no test specified\" && exit 1"
10-
},
11-
"repository": {
12-
"type": "git",
13-
"url": "[email protected]:KunalKapadia/express-es6-rest-api-starter.git"
14-
},
15-
"author": "Kunal Kapadia <[email protected]>",
16-
"dependencies": {
17-
"body-parser": "~1.13.2",
18-
"compression": "^1.6.1",
19-
"cors": "^2.7.1",
20-
"debug": "^2.2.0",
21-
"dotenv": "^2.0.0",
22-
"express": "~4.13.1",
23-
"http-status": "^0.2.0",
24-
"method-override": "^2.3.5",
25-
"morgan": "~1.6.1"
26-
},
27-
"devDependencies": {
28-
"babel": "^5.8.23",
29-
"del": "^2.2.0",
30-
"gulp-babel": "^5.2.1",
31-
"gulp-load-plugins": "^1.2.0",
32-
"gulp-newer": "^1.1.0",
33-
"gulp-nodemon": "^2.0.6",
34-
"gulp-plumber": "^1.0.1",
35-
"gulp-sourcemaps": "^1.6.0"
36-
}
2+
"name": "express-es6-rest-api-starter",
3+
"version": "0.1.0",
4+
"description": "Starter project for an ES6 RESTful Express API",
5+
"main": "index.js",
6+
"private": false,
7+
"scripts": {
8+
"start": "gulp serve",
9+
"test": "echo \"Error: no test specified\" && exit 1"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "[email protected]:KunalKapadia/express-es6-rest-api-starter.git"
14+
},
15+
"author": "Kunal Kapadia <[email protected]>",
16+
"dependencies": {
17+
"body-parser": "~1.13.2",
18+
"compression": "^1.6.1",
19+
"cors": "^2.7.1",
20+
"debug": "^2.2.0",
21+
"dotenv": "^2.0.0",
22+
"express": "~4.13.1",
23+
"http-status": "^0.2.0",
24+
"method-override": "^2.3.5",
25+
"morgan": "~1.6.1"
26+
},
27+
"devDependencies": {
28+
"babel": "^5.8.23",
29+
"del": "^2.2.0",
30+
"gulp-babel": "^5.2.1",
31+
"gulp-load-plugins": "^1.2.0",
32+
"gulp-newer": "^1.1.0",
33+
"gulp-nodemon": "^2.0.6",
34+
"gulp-plumber": "^1.0.1",
35+
"gulp-sourcemaps": "^1.6.0",
36+
"run-sequence": "^1.1.5"
37+
}
3738
}

0 commit comments

Comments
 (0)