Skip to content

Instantly share code, notes, and snippets.

@Xowap
Created November 13, 2015 15:59
Show Gist options
  • Save Xowap/a2dc33f7ba0068b761de to your computer and use it in GitHub Desktop.
Save Xowap/a2dc33f7ba0068b761de to your computer and use it in GitHub Desktop.
Gulpfile for Django (single app)
'use strict';
const DIST_DIR = 'gif/static';
const SRC_DIR = 'gif/static_src';
const MAPS_DIR = 'maps';
const JS_SRC = [
'node_modules/angular/angular.js',
'node_modules/angular-route/angular-route.js',
'node_modules/angular-touch/angular-touch.js',
'node_modules/angular-carousel/dist/angular-carousel.js',
'node_modules/babel-polyfill/dist/polyfill.js'
];
const ES6_SRC = [
SRC_DIR + '/*.js'
];
const LESS_SRC = [
SRC_DIR + '/reset.less',
SRC_DIR + '/fonts.less',
'node_modules/angular-carousel/dist/angular-carousel.css',
SRC_DIR + '/app.less'
];
const gulp = require('gulp');
const babel = require('gulp-babel');
const sourcemaps = require('gulp-sourcemaps');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const less = require('gulp-less');
const LessPluginCleanCSS = require('less-plugin-clean-css');
const LessPluginAutoPrefix = require('less-plugin-autoprefix');
const cleancss = new LessPluginCleanCSS({advanced: true});
const autoprefix = new LessPluginAutoPrefix({browsers: ["last 2 versions"]});
gulp.task('build:js', () => {
return gulp.src(JS_SRC)
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(concat('libs.js'))
.pipe(sourcemaps.write(MAPS_DIR))
.pipe(gulp.dest(DIST_DIR));
});
gulp.task('build:es6', () => {
return gulp.src(ES6_SRC)
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['babel-preset-es2015']
}))
.pipe(uglify())
.pipe(concat('script.js'))
.pipe(sourcemaps.write(MAPS_DIR))
.pipe(gulp.dest(DIST_DIR));
});
gulp.task('build:less', () => {
return gulp.src(LESS_SRC)
.pipe(sourcemaps.init())
.pipe(less({
plugins: [autoprefix, cleancss]
}))
.pipe(concat('style.css'))
.pipe(sourcemaps.write(MAPS_DIR))
.pipe(gulp.dest(DIST_DIR));
});
gulp.task('build:assets', [
'build:js',
'build:es6',
'build:less'
]);
gulp.task('roll', ['build:assets'], () => {
gulp.watch(JS_SRC, ['build:js']);
gulp.watch(ES6_SRC, ['build:es6']);
gulp.watch(LESS_SRC, ['build:less']);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment