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.

94 lines
2.7 KiB

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