Skip to content

Instantly share code, notes, and snippets.

@gabrielhpugliese
Last active January 31, 2019 09:08
Show Gist options
  • Save gabrielhpugliese/13aba32c0ba3f856332c to your computer and use it in GitHub Desktop.
Save gabrielhpugliese/13aba32c0ba3f856332c to your computer and use it in GitHub Desktop.
Django collectstatic + Gulp watch
var gulp = require('gulp');
var shell = require('gulp-shell');
var changed = require('gulp-changed');
gulp.task('collectstatic', function () {
return gulp.src('static/**/*.*')
.pipe(changed('YOURAPP/static/'))
.pipe(shell([
'python manage.py collectstatic --noinput'
]));
});
gulp.task('watch', function () {
gulp.watch('static/**/*.*', ['collectstatic']);
});
@robbintt
Copy link

robbintt commented Nov 5, 2015

Might consider using python manage.py collectstatic -i node_modules -i bower_components --noinput.

I also forked this gist and I believe I've used better security practices... as outlined by gulp's blacklist and gulp-exec:
https://www.npmjs.com/package/gulp-exec
https://github.com/gulpjs/plugins/blob/master/src/blackList.json

@maniqui
Copy link

maniqui commented Mar 22, 2016

@robbintt, thanks for sharing this gist.
I'm trying to figure out your use case for it.

Am I right if I say that this gist is useful when developing in a Django environment that is somewhat "production-like"? That is, instead of using the Django built-in development server, the gist is most useful when using something like Apache+mod_wsgi for serving the website on a development environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment