-
-
Save robbintt/54e97da94e02fc3c8ac9 to your computer and use it in GitHub Desktop.
Django collectstatic + Gulp watch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
// Run shell commands with exec: | |
// https://www.npmjs.com/package/gulp-exec | |
var exec = require('child_process').exec; | |
// collectstatic task for Django | |
// https://www.npmjs.com/package/gulp-exec | |
gulp.task('collectstatic', function (cb) { | |
exec('python ../../manage.py collectstatic -i node_modules -i bower_components --noinput', function (err, stdout, stderr) { | |
console.log(stdout); | |
console.log(stderr); | |
cb(err); | |
}); | |
}); | |
// collectstatic should be added to the end of each watch command rather than initalizing alone. | |
//gulp.task('watch', function () { | |
// gulp.watch('static/**/*.*', ['collectstatic']); | |
//}); |
I also added some output to gulp watch to remind me to enter a virtual environment (have django and requirements installed to run manage.py).
Note gulp 4.x: Pass a gulp.series()
invocation with only one task name.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Noted gulp-shell is blacklisted for antipatterns, tried gulp-exec but found they recommended not using their plugin for this very simple use-case. This pattern is modified from the howto on gulp-exec.
https://www.npmjs.com/package/gulp-exec
https://github.com/gulpjs/plugins/blob/master/src/blackList.json