example gulpfile to work with django

Django -- Posted on April 30, 2022

This is a Gulp configuration file used to automate various tasks for a web development project. It utilizes various Gulp plugins to minify CSS and JavaScript files, concatenate them, and reload the browser automatically whenever changes are made to the source files.


                const { parallel, src, dest, watch, series } = require('gulp');
const gulp = require("gulp");
let rename = require("gulp-rename");
const cleanCSS = require('gulp-clean-css');
const minify = require('gulp-minify');
let wrap = require('gulp-wrap');
let declare = require('gulp-declare');
let concat = require('gulp-concat');
let exec = require('child_process').exec;
const browsersync = require('browser-sync').create();
let spawn = require('child_process').spawn;

function css(){
  return gulp.src([
     .pipe(cleanCSS({compatibility: 'ie8'}))
       stream: true

function vendor(){
  return gulp.src([
       stream: true

function browsersyncServe(cb){
          notify: false,
          proxy: "localhost:8000"
  browsersync.watch('static/src/css/**/*.css', series(css));
  browsersync.watch('static/src/js/**/*.js', series(vendor));
  browsersync.watch('templates/**/*.html', browsersync.reload);
  browsersync.watch('templates/*.html', browsersync.reload);

function runServer(){
  var cmd = spawn('venv/Scripts/python.exe', ['manage.py', 'runserver'], {stdio: 'inherit'});
  cmd.on('close', function(code) {
    console.log('runServer exited with code ' + code);

exports.css = css;
exports.vendor = vendor;
exports.runServer = runServer;
exports.browsersyncServe = browsersyncServe;
exports.default = parallel(css, vendor, runServer, browsersyncServe);

Related Posts