mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-21 07:15:13 +03:00
Cleanup gulpfile.js, fix minification
Move outputDir to a constant. Add an output variable which contains the filenames for each output file. Remove usage of 'let' and 'for(... of [Object])' from osd.js, since uglify doesn't support ES6 and babel failed on google-analytics-bundle.js Fix 'deploy-receiver-css'. uglify() was being called as part of the pipeline instead of the correct minifyCSS() call. Let npm sort the deps rather than editing them manually Add missing openlayers dependency
This commit is contained in:
parent
edef72f985
commit
14f9cb80df
3 changed files with 75 additions and 57 deletions
100
gulpfile.js
100
gulpfile.js
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
var gulp = require('gulp');
|
var gulp = require('gulp');
|
||||||
var rename = require('gulp-rename');
|
var rename = require('gulp-rename');
|
||||||
var uglify = require('gulp-uglify');
|
var uglify = require('gulp-uglify');
|
||||||
|
@ -19,20 +21,6 @@ sources.css = [
|
||||||
'./js/libraries/jbox/jBox.css'
|
'./js/libraries/jbox/jBox.css'
|
||||||
];
|
];
|
||||||
|
|
||||||
sources.receiver = [
|
|
||||||
'./node_modules/jquery/dist/jquery.min.js',
|
|
||||||
'./node_modules/jquery-ui-npm/jquery-ui.min.js',
|
|
||||||
'./js/libraries/jquery.nouislider.all.min.js',
|
|
||||||
'./tabs/receiver_msp.js'
|
|
||||||
];
|
|
||||||
|
|
||||||
sources.receiverCss = [
|
|
||||||
'./css/opensans_webfontkit/fonts.css',
|
|
||||||
'./js/libraries/jquery.nouislider.min.css',
|
|
||||||
'./js/libraries/jquery.nouislider.pips.min.css',
|
|
||||||
'./tabs/receiver_msp.css'
|
|
||||||
];
|
|
||||||
|
|
||||||
sources.js = [
|
sources.js = [
|
||||||
'./js/libraries/google-analytics-bundle.js',
|
'./js/libraries/google-analytics-bundle.js',
|
||||||
'./node_modules/jquery/dist/jquery.min.js',
|
'./node_modules/jquery/dist/jquery.min.js',
|
||||||
|
@ -81,89 +69,115 @@ sources.js = [
|
||||||
'./js/peripherals.js'
|
'./js/peripherals.js'
|
||||||
];
|
];
|
||||||
|
|
||||||
sources.mapJs = [
|
|
||||||
'./node_modules/openlayers/dist/ol.js'
|
|
||||||
];
|
|
||||||
|
|
||||||
sources.mapCss = [
|
sources.mapCss = [
|
||||||
'./node_modules/openlayers/dist/ol.css'
|
'./node_modules/openlayers/dist/ol.css'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
sources.mapJs = [
|
||||||
|
'./node_modules/openlayers/dist/ol.js'
|
||||||
|
];
|
||||||
|
|
||||||
|
sources.receiverCss = [
|
||||||
|
'./css/opensans_webfontkit/fonts.css',
|
||||||
|
'./js/libraries/jquery.nouislider.min.css',
|
||||||
|
'./js/libraries/jquery.nouislider.pips.min.css',
|
||||||
|
'./tabs/receiver_msp.css'
|
||||||
|
];
|
||||||
|
|
||||||
|
sources.receiverJs = [
|
||||||
|
'./node_modules/jquery/dist/jquery.min.js',
|
||||||
|
'./node_modules/jquery-ui-npm/jquery-ui.min.js',
|
||||||
|
'./js/libraries/jquery.nouislider.all.min.js',
|
||||||
|
'./tabs/receiver_msp.js'
|
||||||
|
];
|
||||||
|
|
||||||
|
var output = {
|
||||||
|
css: 'styles.css',
|
||||||
|
js: 'script.js',
|
||||||
|
mapCss: 'map.css',
|
||||||
|
mapJs: 'map.js',
|
||||||
|
receiverCss: 'receiver-msp.css',
|
||||||
|
receiverJs: 'receiver-msp.js',
|
||||||
|
};
|
||||||
|
|
||||||
|
var outputDir = './build/';
|
||||||
|
|
||||||
gulp.task('build-css', function () {
|
gulp.task('build-css', function () {
|
||||||
|
|
||||||
return gulp.src(sources.css)
|
return gulp.src(sources.css)
|
||||||
.pipe(concat('styles.css'))
|
.pipe(concat(output.css))
|
||||||
.pipe(gulp.dest('./build/'));
|
.pipe(gulp.dest(outputDir));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('build-js', function () {
|
gulp.task('build-js', function () {
|
||||||
|
|
||||||
return gulp.src(sources.js)
|
return gulp.src(sources.js)
|
||||||
.pipe(concat('script.js'))
|
.pipe(concat(output.js))
|
||||||
.pipe(gulp.dest('./build/'));
|
.pipe(gulp.dest(outputDir));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('build-map-css', function () {
|
gulp.task('build-map-css', function () {
|
||||||
|
|
||||||
return gulp.src(sources.mapCss)
|
return gulp.src(sources.mapCss)
|
||||||
.pipe(concat('map.css'))
|
.pipe(concat(output.mapCss))
|
||||||
.pipe(gulp.dest('./build/'));
|
.pipe(gulp.dest(outputDir));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('build-map-js', function () {
|
gulp.task('build-map-js', function () {
|
||||||
|
|
||||||
return gulp.src(sources.mapJs)
|
return gulp.src(sources.mapJs)
|
||||||
.pipe(concat('map.js'))
|
.pipe(concat(output.mapJs))
|
||||||
.pipe(gulp.dest('./build/'));
|
.pipe(gulp.dest(outputDir));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('deploy-css', function () {
|
gulp.task('deploy-css', function () {
|
||||||
|
|
||||||
return gulp.src(sources.css)
|
return gulp.src(sources.css)
|
||||||
.pipe(concat('styles.css'))
|
.pipe(concat(output.css))
|
||||||
.pipe(minifyCSS())
|
.pipe(minifyCSS())
|
||||||
.pipe(gulp.dest('./build/'));
|
.pipe(gulp.dest(outputDir));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('deploy-js', function () {
|
gulp.task('deploy-js', function () {
|
||||||
|
|
||||||
return gulp.src(sources.js)
|
return gulp.src(sources.js)
|
||||||
.pipe(concat('script.js'))
|
.pipe(concat(output.js))
|
||||||
.pipe(uglify())
|
.pipe(uglify())
|
||||||
.pipe(gulp.dest('./build/'));
|
.pipe(gulp.dest(outputDir));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('build-receiver-css', function () {
|
gulp.task('build-receiver-css', function () {
|
||||||
|
|
||||||
return gulp.src(sources.receiverCss)
|
return gulp.src(sources.receiverCss)
|
||||||
.pipe(concat('receiver-msp.css'))
|
.pipe(concat(output.receiverCss))
|
||||||
.pipe(gulp.dest('./build/'));
|
.pipe(gulp.dest(outputDir));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('deploy-receiver-css', function () {
|
gulp.task('deploy-receiver-css', function () {
|
||||||
|
|
||||||
return gulp.src(sources.receiverCss)
|
return gulp.src(sources.receiverCss)
|
||||||
.pipe(concat('receiver-msp.css'))
|
.pipe(concat(output.receiverCss))
|
||||||
.pipe(uglify())
|
.pipe(minifyCSS())
|
||||||
.pipe(gulp.dest('./build/'));
|
.pipe(gulp.dest(outputDir));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('build-receiver-msp-js', function () {
|
gulp.task('build-receiver-msp-js', function () {
|
||||||
|
|
||||||
return gulp.src(sources.receiver)
|
return gulp.src(sources.receiverJs)
|
||||||
.pipe(concat('receiver-msp.js'))
|
.pipe(concat(output.receiverJs))
|
||||||
.pipe(gulp.dest('./build/'));
|
.pipe(gulp.dest(outputDir));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('deploy-receiver-msp-js', function () {
|
gulp.task('deploy-receiver-msp-js', function () {
|
||||||
|
|
||||||
return gulp.src(sources.receiver)
|
return gulp.src(sources.receiverJs)
|
||||||
.pipe(concat('receiver-msp.js'))
|
.pipe(concat(output.receiverJs))
|
||||||
.pipe(uglify())
|
.pipe(uglify())
|
||||||
.pipe(gulp.dest('./build/'));
|
.pipe(gulp.dest(outputDir));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('deploy', ['deploy-css', 'deploy-js', 'deploy-receiver-msp-js', 'deploy-receiver-css']);
|
gulp.task('build', ['build-css', 'build-js', 'build-receiver-css', 'build-receiver-msp-js', 'build-map-css', 'build-map-js']);
|
||||||
|
gulp.task('deploy', ['deploy-css', 'deploy-js', 'deploy-receiver-css', 'deploy-receiver-msp-js']);
|
||||||
|
|
||||||
gulp.task('watch', function () {
|
gulp.task('watch', function () {
|
||||||
gulp.watch('js/**/*.js', ['build-js']);
|
gulp.watch('js/**/*.js', ['build-js']);
|
||||||
|
@ -175,4 +189,4 @@ gulp.task('watch', function () {
|
||||||
gulp.watch('eventPage.js', ['build-js']);
|
gulp.watch('eventPage.js', ['build-js']);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('default', ['build-js', 'build-css', 'build-receiver-msp-js', 'build-receiver-css', 'build-map-js', 'build-map-css']);
|
gulp.task('default', ['build']);
|
||||||
|
|
19
package.json
19
package.json
|
@ -5,7 +5,7 @@
|
||||||
"main": "main.html",
|
"main": "main.html",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node_modules/nw/bin/nw ."
|
"start": "node_modules/gulp/bin/gulp.js build && node_modules/nw/bin/nw ."
|
||||||
},
|
},
|
||||||
"window": {
|
"window": {
|
||||||
"title": "INAV Configurator",
|
"title": "INAV Configurator",
|
||||||
|
@ -21,16 +21,19 @@
|
||||||
"author": "iNavFlight",
|
"author": "iNavFlight",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"nw": "^0.24.4-sdk",
|
|
||||||
"jquery": "2.1.4",
|
|
||||||
"jquery-ui-npm": "1.12.0",
|
|
||||||
"three": "0.72.0",
|
|
||||||
"inflection": "1.12.0",
|
|
||||||
"bluebird": "3.4.1",
|
"bluebird": "3.4.1",
|
||||||
|
"del": "^3.0.0",
|
||||||
"gulp": "~3.9.1",
|
"gulp": "~3.9.1",
|
||||||
|
"gulp-concat": "~2.6.1",
|
||||||
|
"gulp-minify-css": "~1.2.4",
|
||||||
"gulp-rename": "~1.2.2",
|
"gulp-rename": "~1.2.2",
|
||||||
"gulp-uglify": "~3.0.0",
|
"gulp-uglify": "~3.0.0",
|
||||||
"gulp-concat": "~2.6.1",
|
"inflection": "1.12.0",
|
||||||
"gulp-minify-css": "~1.2.4"
|
"jquery": "2.1.4",
|
||||||
|
"jquery-ui-npm": "1.12.0",
|
||||||
|
"nw": "^0.24.4-sdk",
|
||||||
|
"nw-builder": "^3.4.1",
|
||||||
|
"openlayers": "^4.3.1",
|
||||||
|
"three": "0.72.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
tabs/osd.js
13
tabs/osd.js
|
@ -747,7 +747,7 @@ TABS.osd.initialize = function (callback) {
|
||||||
// alarms
|
// alarms
|
||||||
$('.alarms-container').show();
|
$('.alarms-container').show();
|
||||||
var $alarms = $('.alarms').empty();
|
var $alarms = $('.alarms').empty();
|
||||||
for (let k in OSD.data.alarms) {
|
for (var k in OSD.data.alarms) {
|
||||||
var alarm = OSD.data.alarms[k];
|
var alarm = OSD.data.alarms[k];
|
||||||
var alarmInput = $('<input name="alarm" type="number" id="' + k + '"/>' + alarm.display_name + '</label>');
|
var alarmInput = $('<input name="alarm" type="number" id="' + k + '"/>' + alarm.display_name + '</label>');
|
||||||
alarmInput.val(alarm.value);
|
alarmInput.val(alarm.value);
|
||||||
|
@ -764,9 +764,8 @@ TABS.osd.initialize = function (callback) {
|
||||||
|
|
||||||
// display fields on/off and position
|
// display fields on/off and position
|
||||||
var $displayFields = $('.display-fields').empty();
|
var $displayFields = $('.display-fields').empty();
|
||||||
|
for (var ii = 0; ii < OSD.data.display_items.length; ii++) {
|
||||||
for (let field of OSD.data.display_items) {
|
var field = OSD.data.display_items[ii];
|
||||||
|
|
||||||
// versioning related, if the field doesn't exist at the current flight controller version, just skip it
|
// versioning related, if the field doesn't exist at the current flight controller version, just skip it
|
||||||
if (!field.name) {
|
if (!field.name) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -822,7 +821,8 @@ TABS.osd.initialize = function (callback) {
|
||||||
// buffer the preview
|
// buffer the preview
|
||||||
OSD.data.preview = [];
|
OSD.data.preview = [];
|
||||||
OSD.data.display_size.total = OSD.data.display_size.x * OSD.data.display_size.y;
|
OSD.data.display_size.total = OSD.data.display_size.x * OSD.data.display_size.y;
|
||||||
for (let field of OSD.data.display_items) {
|
for (var ii = 0; ii < OSD.data.display_items.length; ii++) {
|
||||||
|
var field = OSD.data.display_items[ii];
|
||||||
// reset fields that somehow end up off the screen
|
// reset fields that somehow end up off the screen
|
||||||
if (field.position > OSD.data.display_size.total) {
|
if (field.position > OSD.data.display_size.total) {
|
||||||
field.position = 0;
|
field.position = 0;
|
||||||
|
@ -835,7 +835,8 @@ TABS.osd.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw all the displayed items and the drag and drop preview images
|
// draw all the displayed items and the drag and drop preview images
|
||||||
for (let field of OSD.data.display_items) {
|
for (var ii = 0; ii < OSD.data.display_items.length; ii++) {
|
||||||
|
var field = OSD.data.display_items[ii];
|
||||||
if (!field.preview || !field.isVisible) {
|
if (!field.preview || !field.isVisible) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue