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.

92 lines
2.6 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 plumber = require('gulp-plumber');
  20. const htmlmin = require('gulp-htmlmin');
  21. const cleancss = require('gulp-clean-css');
  22. const uglify = require('gulp-uglify');
  23. const gzip = require('gulp-gzip');
  24. const del = require('del');
  25. const useref = require('gulp-useref');
  26. const gulpif = require('gulp-if');
  27. const inline = require('gulp-inline');
  28. /* Clean destination folder */
  29. gulp.task('clean', function() {
  30. del(['data/*']);
  31. return true;
  32. });
  33. /* Copy static files */
  34. gulp.task('files', function() {
  35. return gulp.src([
  36. 'html/**/*.{jpg,jpeg,png,ico,gif}',
  37. 'html/fsversion'
  38. ])
  39. .pipe(gulp.dest('data/'));
  40. });
  41. /* Process HTML, CSS, JS --- INLINE --- */
  42. gulp.task('inline', function() {
  43. return gulp.src('html/*.html')
  44. .pipe(inline({
  45. base: 'html/',
  46. js: uglify,
  47. css: cleancss,
  48. disabledTypes: ['svg', 'img']
  49. }))
  50. .pipe(htmlmin({
  51. collapseWhitespace: true,
  52. removeComments: true,
  53. minifyCSS: true,
  54. minifyJS: true
  55. }))
  56. .pipe(gzip())
  57. .pipe(gulp.dest('data'));
  58. })
  59. /* Process HTML, CSS, JS */
  60. gulp.task('html', function() {
  61. return gulp.src('html/*.html')
  62. .pipe(useref())
  63. .pipe(plumber())
  64. .pipe(gulpif('*.css', cleancss()))
  65. .pipe(gulpif('*.js', uglify()))
  66. .pipe(gulpif('*.html', htmlmin({
  67. collapseWhitespace: true,
  68. removeComments: true,
  69. minifyCSS: true,
  70. minifyJS: true
  71. })))
  72. .pipe(gzip())
  73. .pipe(gulp.dest('data'));
  74. });
  75. /* Build file system */
  76. gulp.task('buildfs', ['clean', 'files', 'html']);
  77. gulp.task('buildfs2', ['clean', 'files', 'inline']);
  78. gulp.task('default', ['buildfs']);