Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.0 KiB

8 years ago
8 years ago
8 years ago
8 years ago
  1. /*
  2. ESP8266 file system builder
  3. Copyright (C) 2016 by Xose Pérez <xose dot perez at gmail dot com>
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. // -----------------------------------------------------------------------------
  16. // File system builder
  17. // -----------------------------------------------------------------------------
  18. const gulp = require('gulp');
  19. const htmlmin = require('gulp-htmlmin');
  20. const cleancss = require('gulp-clean-css');
  21. const uglify = require('gulp-uglify');
  22. const gzip = require('gulp-gzip');
  23. const del = require('del');
  24. const inline = require('gulp-inline');
  25. /* Clean destination folder */
  26. gulp.task('clean', function() {
  27. del(['data/*']);
  28. return true;
  29. });
  30. /* Copy static files */
  31. gulp.task('files', function() {
  32. return gulp.src([
  33. 'html/**/*.{jpg,jpeg,png,ico,gif}',
  34. 'html/fsversion'
  35. ])
  36. .pipe(gulp.dest('data/'));
  37. });
  38. /* Process HTML, CSS, JS --- INLINE --- */
  39. gulp.task('inline', function() {
  40. return gulp.src('html/*.html')
  41. .pipe(inline({
  42. base: 'html/',
  43. js: uglify,
  44. css: cleancss,
  45. disabledTypes: ['svg', 'img']
  46. }))
  47. .pipe(htmlmin({
  48. collapseWhitespace: true,
  49. removeComments: true,
  50. minifyCSS: true,
  51. minifyJS: true
  52. }))
  53. .pipe(gzip())
  54. .pipe(gulp.dest('data'));
  55. })
  56. /* Build file system */
  57. gulp.task('buildfs', ['clean', 'files', 'inline']);
  58. gulp.task('default', ['buildfs']);