mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 13:32:15 +00:00
More optimisation and cleanup (#420)
This commit is contained in:
70
gulpfile.js
70
gulpfile.js
@@ -2,40 +2,52 @@
|
||||
|
||||
var gulp = require('gulp');
|
||||
|
||||
var terser = require('gulp-terser');
|
||||
var sass = require('gulp-sass');
|
||||
var flatten = require('gulp-flatten');
|
||||
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");
|
||||
var spawn = require('child_process').spawn;
|
||||
const terser = require('gulp-uglify');
|
||||
const sass = require('gulp-sass');
|
||||
const flatten = require('gulp-flatten');
|
||||
const autoprefixer = require('autoprefixer')
|
||||
const postcss = require('gulp-postcss')
|
||||
const sourcemaps = require('gulp-sourcemaps');
|
||||
const browsersync = require('browser-sync').create();
|
||||
const { exec } = require("child_process");
|
||||
const spawn = require('child_process').spawn;
|
||||
const cssnano = require('cssnano');
|
||||
const con = require('gulp-concat');
|
||||
const gulpif = require('gulp-if');
|
||||
|
||||
sass.compiler = require('node-sass');
|
||||
|
||||
function fonts(done) {
|
||||
return gulp.src('node_modules/@fortawesome/fontawesome-free/webfonts/fa-solid-900.*')
|
||||
.pipe(gulp.dest('pipeline/built_assets/fonts'))
|
||||
.pipe(browsersync.stream());
|
||||
}
|
||||
|
||||
function styles(done) {
|
||||
const bs_select = ["bootstrap-select.css", "ajax-bootstrap-select.css"]
|
||||
return gulp.src(['pipeline/source_assets/scss/**/*.scss',
|
||||
'node_modules/fullcalendar/main.min.css',
|
||||
'node_modules/fullcalendar/main.css',
|
||||
'node_modules/bootstrap-select/dist/css/bootstrap-select.css',
|
||||
'node_modules/ajax-bootstrap-select/dist/css/ajax-bootstrap-select.css',
|
||||
'node_modules/flatpickr/dist/flatpickr.css'])
|
||||
'node_modules/flatpickr/dist/flatpickr.css',])
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(sass().on('error', sass.logError))
|
||||
.pipe(postcss([ autoprefixer() ]))
|
||||
.pipe(gulpif(function(file) { return bs_select.includes(file.relative);}, con('selects.css')))
|
||||
.pipe(postcss([ autoprefixer(), cssnano() ]))
|
||||
.pipe(sourcemaps.write())
|
||||
.pipe(gulp.dest('pipeline/built_assets/css'))
|
||||
.pipe(browsersync.stream());
|
||||
}
|
||||
|
||||
function scripts() {
|
||||
return gulp.src(['pipeline/source_assets/js/**/*.js',
|
||||
'node_modules/jquery/dist/jquery.js',
|
||||
const dest = 'pipeline/built_assets/js';
|
||||
const base_scripts = ["src.js", "util.js", "alert.js", "collapse.js", "dropdown.js", "modal.js", "konami.js"];
|
||||
const bs_select = ["bootstrap-select.js", "ajax-bootstrap-select.js"]
|
||||
const interaction = ["html5sortable.min.js", "interaction.js"]
|
||||
const jpop = ["jquery.min.js", "popper.min.js"]
|
||||
return gulp.src(['node_modules/jquery/dist/jquery.min.js',
|
||||
/* JQuery Plugins */
|
||||
'node_modules/jquery-ui-dist/jquery-ui.js',
|
||||
|
||||
'node_modules/popper.js/dist/umd/popper.js',
|
||||
'node_modules/raven-js/dist/raven.js', //TODO Upgrade to Sentry
|
||||
'node_modules/popper.js/dist/umd/popper.min.js',
|
||||
/* Bootstrap Plugins */
|
||||
'node_modules/bootstrap/js/dist/util.js',
|
||||
'node_modules/bootstrap/js/dist/tooltip.js',
|
||||
@@ -45,18 +57,22 @@ function scripts() {
|
||||
'node_modules/bootstrap/js/dist/modal.js',
|
||||
'node_modules/bootstrap/js/dist/alert.js',
|
||||
|
||||
'node_modules/html5sortable/dist/html5sortable.min.js',
|
||||
'node_modules/clipboard/dist/clipboard.min.js',
|
||||
'node_modules/flatpickr/dist/flatpickr.min.js',
|
||||
'node_modules/@fortawesome/fontawesome-free/js/all.js',
|
||||
'node_modules/moment/moment.js',
|
||||
'node_modules/fullcalendar/main.min.js',
|
||||
'node_modules/fullcalendar/main.js',
|
||||
'node_modules/bootstrap-select/dist/js/bootstrap-select.js',
|
||||
'node_modules/ajax-bootstrap-select/dist/js/ajax-bootstrap-select.js',
|
||||
'node_modules/konami/konami.js',
|
||||
'node_modules/dark-mode-switch/dark-mode-switch.min.js'])
|
||||
'pipeline/source_assets/js/**/*.js',])
|
||||
.pipe(gulpif(function(file) { return base_scripts.includes(file.relative);}, con('base.js')))
|
||||
.pipe(gulpif(function(file) { return bs_select.includes(file.relative);}, con('selects.js')))
|
||||
.pipe(gulpif(function(file) { return interaction.includes(file.relative);}, con('interaction.js')))
|
||||
.pipe(gulpif(function(file) { return jpop.includes(file.relative);}, con('jpop.js')))
|
||||
.pipe(flatten())
|
||||
.pipe(terser())
|
||||
.pipe(gulp.dest('pipeline/built_assets/js'))
|
||||
.pipe(gulp.dest(dest))
|
||||
.pipe(browsersync.stream());
|
||||
}
|
||||
|
||||
@@ -64,7 +80,8 @@ function browserSync(done) {
|
||||
spawn('python', ['manage.py', 'runserver'], {stdio: 'inherit'});
|
||||
// TODO Wait for Django server to come up before browsersync, it seems inconsistent
|
||||
browsersync.init({
|
||||
notify: true,
|
||||
notify: false,
|
||||
open: false,
|
||||
port: 8001,
|
||||
proxy: 'localhost:8000'
|
||||
});
|
||||
@@ -77,11 +94,10 @@ function browserSyncReload(done) {
|
||||
}
|
||||
|
||||
function watchFiles() {
|
||||
gulp.watch("RIGS/static/scss/**/*.scss", styles);
|
||||
// TODO This prevents reload looping, but means we don't reload if new third party scripts are added
|
||||
gulp.watch("RIGS/static/js/src/**/*.js", scripts);
|
||||
gulp.watch("pipeline/source_assets/scss/**/*.scss", styles);
|
||||
gulp.watch("pipeline/source_assets/js/**/*.js", scripts);
|
||||
gulp.watch("**/templates/*.html", browserSyncReload);
|
||||
}
|
||||
|
||||
exports.build = gulp.parallel(styles, scripts);
|
||||
exports.build = gulp.parallel(styles, scripts, fonts);
|
||||
exports.watch = gulp.parallel(watchFiles, browserSync);
|
||||
|
||||
Reference in New Issue
Block a user