Setup gulp watch for dev
parent
12c110440f
commit
8373dfc430
27
gulpfile.js
27
gulpfile.js
|
@ -1,10 +1,21 @@
|
||||||
const { src, dest, series } = require('gulp');
|
const { src, dest, series, watch } = require('gulp');
|
||||||
const gulp = require('gulp');
|
const gulp = require('gulp');
|
||||||
|
const nodemon = require('gulp-nodemon');
|
||||||
const less = require('gulp-less');
|
const less = require('gulp-less');
|
||||||
|
const colors = require('colors');
|
||||||
const cleanCSS = require('gulp-clean-css');
|
const cleanCSS = require('gulp-clean-css');
|
||||||
const minify = require('gulp-minify');
|
const minify = require('gulp-minify');
|
||||||
const rename = require('gulp-rename');
|
const rename = require('gulp-rename');
|
||||||
|
|
||||||
|
const nodemonOptions = {
|
||||||
|
script: 'app.js',
|
||||||
|
ext: 'js json',
|
||||||
|
env: { NODE_ENV: 'development' },
|
||||||
|
verbose: false,
|
||||||
|
ignore: [],
|
||||||
|
watch: ['lib/*', 'config/*', 'routes/*', 'app.js']
|
||||||
|
};
|
||||||
|
|
||||||
function lessCss(){
|
function lessCss(){
|
||||||
return gulp.src('public/stylesheets/less/**/*.less')
|
return gulp.src('public/stylesheets/less/**/*.less')
|
||||||
.pipe(less({
|
.pipe(less({
|
||||||
|
@ -74,3 +85,17 @@ function compressThemeJS(){
|
||||||
|
|
||||||
// run the tasks
|
// run the tasks
|
||||||
gulp.task('default', series(lessCss, compressJS, compressCss, compressThemeCss, compressThemeJS));
|
gulp.task('default', series(lessCss, compressJS, compressCss, compressThemeCss, compressThemeJS));
|
||||||
|
|
||||||
|
gulp.task('watch', (done) => {
|
||||||
|
// Watch LESS files and generate CSS
|
||||||
|
watch(['public/stylesheets/less/**/*.less'], async () => {
|
||||||
|
lessCss();
|
||||||
|
console.log(colors.blue('CSS generation complete'));
|
||||||
|
});
|
||||||
|
|
||||||
|
// run, watch and restart app
|
||||||
|
nodemon(nodemonOptions)
|
||||||
|
.once('quit', () => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8,7 +8,7 @@
|
||||||
"deploy": "gulp deploy",
|
"deploy": "gulp deploy",
|
||||||
"testdata": "node lib/testdata.js",
|
"testdata": "node lib/testdata.js",
|
||||||
"test": "ava",
|
"test": "ava",
|
||||||
"dev": "nodemon app.js",
|
"dev": "gulp watch",
|
||||||
"lint": "eslint ./"
|
"lint": "eslint ./"
|
||||||
},
|
},
|
||||||
"ava": {
|
"ava": {
|
||||||
|
@ -84,6 +84,7 @@
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
"gulp-clean-css": "^3.10.0",
|
"gulp-clean-css": "^3.10.0",
|
||||||
"gulp-minify": "^3.1.0",
|
"gulp-minify": "^3.1.0",
|
||||||
|
"gulp-nodemon": "^2.4.2",
|
||||||
"gulp-rename": "^1.4.0",
|
"gulp-rename": "^1.4.0",
|
||||||
"less": "^3.10.3",
|
"less": "^3.10.3",
|
||||||
"supertest": "^4.0.2"
|
"supertest": "^4.0.2"
|
||||||
|
|
Loading…
Reference in New Issue