mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-24 08:52:15 +00:00
Inital work on adding development livereload
This commit is contained in:
46
gulpfile.js
46
gulpfile.js
@@ -11,26 +11,52 @@ var cleanCSS = require('gulp-clean-css');
|
||||
var autoprefixer = require('autoprefixer')
|
||||
var postcss = require('gulp-postcss')
|
||||
var sourcemaps = require('gulp-sourcemaps');
|
||||
var browsersync = require('browser-sync').create();
|
||||
var { exec } = require("child_process");
|
||||
|
||||
sass.compiler = require('node-sass');
|
||||
|
||||
gulp.task('sass', function () {
|
||||
return gulp.src(['web_assets/scss/**/*.scss', 'node_modules/fullcalendar/dist/fullcalendar.css'])
|
||||
function sass() {
|
||||
return gulp.src(["RIGS/scss/**/*.scss", "node_modules/fullcalendar/dist/fullcalendar.css", 'node_modules/ajax-bootstrap-select/dist/css/ajax-bootstrap-select.min.css', 'node_modules/autocompleter/autocompleter.min.css', 'node_modules/@activix/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css'])
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(flatten())
|
||||
.pipe(sass().on('error', sass.logError))
|
||||
.pipe(cleanCSS({compatibility: 'ie8'}))
|
||||
.pipe(postcss([ autoprefixer() ]))
|
||||
.pipe(sourcemaps.write())
|
||||
.pipe(gulp.dest('RIGS/static/css'));
|
||||
});
|
||||
.pipe(gulp.dest('RIGS/static/css'))
|
||||
.pipe(browsersync.stream());
|
||||
}
|
||||
|
||||
gulp.task('scripts', function() {
|
||||
return gulp.src(['web_assets/js/**/*.js', 'node_modules/bootstrap/**/bootstrap.min.js', 'node_modules/popper\.js/**/popper.js', 'node_modules/moment/min/moment.min.js', 'node_modules/@fortawesome/fontawesome-free/js/all.js', 'node_modules/jquery/dist/jquery.js', 'node_modules/fullcalendar/dist/fullcalendar.js'])
|
||||
function scripts() {
|
||||
return gulp.src([//'RIGS/static/js/**/.js',
|
||||
'node_modules/bootstrap/**/bootstrap.min.js', 'node_modules/popper.js/**/popper.js', 'node_modules/moment/min/moment.min.js', 'node_modules/@fortawesome/fontawesome-free/js/all.js', 'node_modules/jquery/dist/jquery.js', 'node_modules/fullcalendar/dist/fullcalendar.js', 'node_modules/ajax-bootstrap-select/dist/js/ajax-bootstrap-select.min.js', 'node_modules/konami.js', 'node_modules/autocompleter/autocompleter.min.js', 'node_modules/@activix/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'])
|
||||
.pipe(flatten())
|
||||
.pipe(terser())
|
||||
.pipe(gulp.dest('RIGS/static/js'));
|
||||
});
|
||||
.pipe(gulp.dest('RIGS/static/js'))
|
||||
.pipe(browsersync.stream());
|
||||
}
|
||||
|
||||
exports.default = gulp.parallel('sass', 'scripts');
|
||||
exports.build = gulp.parallel('sass', 'scripts');
|
||||
function browserSync(done) {
|
||||
exec('python manage.py runserver');
|
||||
// TODO Wait for Django server to come up before browsersync, it seems inconsistent
|
||||
browsersync.init({
|
||||
notify: true,
|
||||
port: 8001,
|
||||
proxy: 'localhost:8000'
|
||||
});
|
||||
done();
|
||||
}
|
||||
|
||||
function browserSyncReload(done) {
|
||||
browsersync.reload();
|
||||
done();
|
||||
}
|
||||
|
||||
function watchFiles() {
|
||||
gulp.watch("RIGS/static/scss/**/*", sass);
|
||||
gulp.watch("RIGS/static/js/**/*", scripts);
|
||||
gulp.watch(['templates/**/*.html', 'RIGS/templates/**/*.html', 'assets/templates/**/*.html'], browserSyncReload);
|
||||
}
|
||||
|
||||
exports.watch = gulp.parallel(watchFiles, browserSync);
|
||||
|
||||
Reference in New Issue
Block a user