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.

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