Mercurial > piecrust2
annotate gulpfile.js @ 1188:a7c43131d871
bake: Fix file write flushing problem with Python 3.8+
Writing the cache files fails in Python 3.8 because it looks like flushing
behaviour has changed. We need to explicitly flush. And even then, in very
rare occurrences, it looks like it can still run into racing conditions,
so we do a very hacky and ugly "retry" loop when fetching cached data :(
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 15 Jun 2021 22:36:23 -0700 |
parents | 7eb58b5748eb |
children | bfa470063ee2 |
rev | line source |
---|---|
603
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
1 'use strict'; |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
2 |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
3 var gulp = require('gulp'), |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
4 util = require('gulp-util'), |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
5 sass = require('gulp-sass'), |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
6 sourcemaps = require('gulp-sourcemaps'), |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
7 rename = require('gulp-rename'), |
646
87267392a5c1
cm: Update node module versions.
Ludovic Chabant <ludovic@chabant.com>
parents:
616
diff
changeset
|
8 cssnano = require('gulp-cssnano'), |
603
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
9 concat = require('gulp-concat'), |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
10 uglify = require('gulp-uglify'); |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
11 |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
12 // Stylesheets |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
13 gulp.task('sass', function() { |
807
4d0f80b2ba7f
cm: Fix `gulpfile` for FoodTruck.
Ludovic Chabant <ludovic@chabant.com>
parents:
657
diff
changeset
|
14 return gulp.src('piecrust/admin/assets/sass/**/*.scss') |
603
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
15 //.pipe(sourcemaps.init()) |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
16 .pipe(sass({ |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
17 errLogToConsole: true, |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
18 outputStyle: 'compressed', |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
19 includePaths: [ |
1069
dff873f11541
admin: Upgrade Bootstrap, switch icons to Open-Iconic, remove Bower.
Ludovic Chabant <ludovic@chabant.com>
parents:
807
diff
changeset
|
20 'node_modules/bootstrap/scss', |
dff873f11541
admin: Upgrade Bootstrap, switch icons to Open-Iconic, remove Bower.
Ludovic Chabant <ludovic@chabant.com>
parents:
807
diff
changeset
|
21 'node_modules/open-iconic/font/css']})) |
646
87267392a5c1
cm: Update node module versions.
Ludovic Chabant <ludovic@chabant.com>
parents:
616
diff
changeset
|
22 .pipe(cssnano()) |
603
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
23 //.pipe(sourcemaps.write()) |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
24 .pipe(rename({suffix: '.min'})) |
807
4d0f80b2ba7f
cm: Fix `gulpfile` for FoodTruck.
Ludovic Chabant <ludovic@chabant.com>
parents:
657
diff
changeset
|
25 .pipe(gulp.dest('piecrust/admin/static/css')); |
603
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
26 }); |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
27 |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
28 // Javascript |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
29 gulp.task('js', function() { |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
30 return gulp.src([ |
1069
dff873f11541
admin: Upgrade Bootstrap, switch icons to Open-Iconic, remove Bower.
Ludovic Chabant <ludovic@chabant.com>
parents:
807
diff
changeset
|
31 'node_modules/jquery/dist/jquery.min.js', |
dff873f11541
admin: Upgrade Bootstrap, switch icons to Open-Iconic, remove Bower.
Ludovic Chabant <ludovic@chabant.com>
parents:
807
diff
changeset
|
32 'node_modules/bootstrap/dist/js/bootstrap.min.js', |
dff873f11541
admin: Upgrade Bootstrap, switch icons to Open-Iconic, remove Bower.
Ludovic Chabant <ludovic@chabant.com>
parents:
807
diff
changeset
|
33 'node_modules/timeago/jquery.timeago.js', |
807
4d0f80b2ba7f
cm: Fix `gulpfile` for FoodTruck.
Ludovic Chabant <ludovic@chabant.com>
parents:
657
diff
changeset
|
34 'piecrust/admin/assets/js/**/*.js' |
603
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
35 ]) |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
36 .pipe(sourcemaps.init()) |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
37 .pipe(concat('foodtruck.js')) |
646
87267392a5c1
cm: Update node module versions.
Ludovic Chabant <ludovic@chabant.com>
parents:
616
diff
changeset
|
38 //.pipe(uglify()) |
603
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
39 .pipe(sourcemaps.write()) |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
40 .pipe(rename({suffix: '.min'})) |
807
4d0f80b2ba7f
cm: Fix `gulpfile` for FoodTruck.
Ludovic Chabant <ludovic@chabant.com>
parents:
657
diff
changeset
|
41 .pipe(gulp.dest('piecrust/admin/static/js')); |
603
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
42 }); |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
43 |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
44 // Fonts/images |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
45 gulp.task('fonts', function() { |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
46 return gulp.src([ |
1069
dff873f11541
admin: Upgrade Bootstrap, switch icons to Open-Iconic, remove Bower.
Ludovic Chabant <ludovic@chabant.com>
parents:
807
diff
changeset
|
47 'node_modules/open-iconic/font/fonts/*' |
603
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
48 ]) |
807
4d0f80b2ba7f
cm: Fix `gulpfile` for FoodTruck.
Ludovic Chabant <ludovic@chabant.com>
parents:
657
diff
changeset
|
49 .pipe(gulp.dest('piecrust/admin/static/fonts')); |
603
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
50 }); |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
51 |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
52 gulp.task('images', function() { |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
53 return gulp.src([ |
807
4d0f80b2ba7f
cm: Fix `gulpfile` for FoodTruck.
Ludovic Chabant <ludovic@chabant.com>
parents:
657
diff
changeset
|
54 'piecrust/admin/assets/img/*' |
603
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
55 ]) |
807
4d0f80b2ba7f
cm: Fix `gulpfile` for FoodTruck.
Ludovic Chabant <ludovic@chabant.com>
parents:
657
diff
changeset
|
56 .pipe(gulp.dest('piecrust/admin/static/img')); |
603
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
57 }); |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
58 |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
59 // Launch tasks |
1171
7eb58b5748eb
cm: Update gulp/npm stuff.
Ludovic Chabant <ludovic@chabant.com>
parents:
1069
diff
changeset
|
60 gulp.task('default', gulp.parallel(['sass', 'js', 'fonts', 'images'])); |
603
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
61 |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
62 gulp.task('watch', function() { |
1171
7eb58b5748eb
cm: Update gulp/npm stuff.
Ludovic Chabant <ludovic@chabant.com>
parents:
1069
diff
changeset
|
63 gulp.watch('piecrust/admin/assets/sass/**/*.scss', gulp.series('sass')); |
7eb58b5748eb
cm: Update gulp/npm stuff.
Ludovic Chabant <ludovic@chabant.com>
parents:
1069
diff
changeset
|
64 gulp.watch('piecrust/admin/assets/js/**/*.js', gulp.series('js')); |
603
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
65 }); |
7e4e567377cd
cm: Put Bower/Gulp/etc. stuff all at the root.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
66 |