Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

před 3 roky
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #Browsersync - Gulp & Swig Templates
  2. ## Installation/Usage:
  3. To try this example, follow these 4 simple steps.
  4. **Step 1**: Clone this entire repo
  5. ```bash
  6. $ git clone https://github.com/Browsersync/recipes.git bs-recipes
  7. ```
  8. **Step 2**: Move into the directory containing this example
  9. ```bash
  10. $ cd bs-recipes/recipes/gulp.swig
  11. ```
  12. **Step 3**: Install dependencies
  13. ```bash
  14. $ npm install
  15. ```
  16. **Step 4**: Run the example
  17. ```bash
  18. $ npm start
  19. ```
  20. ### Additional Info:
  21. This example will build HTML files from `./app` with `gulp-swig`
  22. and place them into the `dist` folder. Browsersync then serves from that
  23. folder and reloads after the templates are compiled.
  24. ### Preview of `gulpfile.js`:
  25. ```js
  26. var gulp = require('gulp');
  27. var browserSync = require('browser-sync');
  28. var sass = require('gulp-sass');
  29. var swig = require('gulp-swig');
  30. var reload = browserSync.reload;
  31. var src = {
  32. scss: 'app/scss/*.scss',
  33. css: 'app/css',
  34. html: 'app/*.html'
  35. };
  36. // Static Server + watching scss/html files
  37. gulp.task('serve', ['sass'], function() {
  38. browserSync({
  39. server: "./dist"
  40. });
  41. gulp.watch(src.scss, ['sass']);
  42. gulp.watch(src.html, ['templates']);
  43. });
  44. // Swig templates
  45. gulp.task('templates', function() {
  46. return gulp.src(src.html)
  47. .pipe(swig())
  48. .pipe(gulp.dest('./dist'))
  49. .on("end", reload);
  50. });
  51. // Compile sass into CSS
  52. gulp.task('sass', function() {
  53. return gulp.src(src.scss)
  54. .pipe(sass())
  55. .pipe(gulp.dest(src.css))
  56. .pipe(reload({stream: true}));
  57. });
  58. gulp.task('default', ['serve']);
  59. ```