Skip to content

Commit 599a2fa

Browse files
committed
Upgrade frontend pipeline
Using NodeJS 16, replaced gulp scripts with latest instance. CSS is no longer committed, but placed in a dist folder during build
1 parent caac635 commit 599a2fa

File tree

19 files changed

+19182
-11427
lines changed

19 files changed

+19182
-11427
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
.DS_Store
1515
.sass-cache/
1616
.vagrant/
17-
Gemfile.lock
1817
/dist/
1918
/docs/_build/
2019
/env/
2120
/logs/
22-
/web/media
23-
/stats/
21+
/src/frontend/static/frontend/dist/
2422
/src/fluentdemo/settings/local.py
2523
/src/node_modules/
24+
/web/media
25+
/stats/

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ RUN find /usr/local/lib/python3.6/site-packages/ -name '*.po' -delete && \
1717
find /usr/local/lib/python3.6/site-packages/tinymce/ -regextype posix-egrep -not -regex '.*/langs/(en|nl).*\.js' -wholename '*/langs/*.js' -delete
1818

1919
# Node builder
20-
FROM node:12-stretch as frontend-build
20+
FROM node:16-buster as frontend-build
2121
RUN mkdir -p /app/src
2222
WORKDIR /app/src
2323
COPY src/package.json src/package-lock.json /app/src/

src/.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16.8.0

src/frontend/gulp/config.js

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
'use strict';
22

3-
const autoprefixer = require('autoprefixer'),
4-
mqpacker = require('css-mqpacker'),
5-
cssnano = require('cssnano'),
6-
flexbugsFixes = require('postcss-flexbugs-fixes'),
3+
const autoprefixer = require("autoprefixer"),
4+
cleanCSS = require("postcss-clean"),
5+
sortMediaQueries = require('postcss-sort-media-queries'),
6+
cssnano = require("cssnano"),
7+
flexbugsFixes = require("postcss-flexbugs-fixes"),
78
removeSelectors = require("postcss-remove-selectors");
89

9-
const bootstrap = 'node_modules/bootstrap/js/dist/';
10-
const vendor = './frontend/static/frontend/vendor/';
10+
const bootstrap = "node_modules/bootstrap/js/dist/";
11+
const vendor = "./frontend/static/frontend/vendor/";
12+
const frontend_js = "./frontend/static/frontend/js/";
13+
const dist = "./frontend/static/frontend/dist/";
1114

1215
const NODE_ENV = process.env.NODE_ENV;
1316

@@ -65,20 +68,36 @@ let postcss_plugins = [
6568
autoprefixer({
6669
cascade: false
6770
}),
68-
mqpacker({sort: true}) // combine media queries
71+
sortMediaQueries({sort: 'mobile-first'}), // combine media queries
72+
/*
73+
cleanCSS({
74+
//format: "keep-breaks",
75+
level: {
76+
1: {
77+
specialComments: false
78+
},
79+
2: {
80+
all: true
81+
}
82+
}
83+
})
84+
*/
6985
];
7086

71-
if(NODE_ENV === 'production') {
87+
console.log("postcss-clean temporary disabled due to node.getIterator() bug");
88+
89+
if (NODE_ENV === "production") {
7290
postcss_plugins.push(cssnano());
7391
}
7492

7593

7694
module.exports = {
7795
paths: {
78-
sass: './frontend/sass/',
79-
sass_glob: './frontend/sass/**/*.scss',
80-
css: './frontend/static/frontend/css/',
81-
images: './frontend/static/frontend/images/',
96+
sass: "./frontend/sass/",
97+
sass_glob: "./frontend/sass/**/*.scss",
98+
css: "./frontend/static/frontend/css/",
99+
dist: "./frontend/static/frontend/dist/",
100+
images: "./frontend/static/frontend/images/",
82101
vendor: vendor
83102
},
84103

@@ -88,34 +107,31 @@ module.exports = {
88107
'node_modules/jquery/dist/jquery.min.js',
89108
'node_modules/@popperjs/core/dist/umd/popper.min.js'
90109
],
91-
dest: vendor
110+
dest: dist
92111
},
93112
{
94113
src: [
95114
bootstrap + 'util.js',
96115
bootstrap + 'collapse.js', // mobile menu
97116
bootstrap + 'dropdown.js' // menu
98117
],
99-
dest: vendor,
118+
dest: dist,
100119
concat: "bootstrap.min.js",
101120
minify: true
102121
}
103122
],
104123

105124
sass_options: {
106125
// See https://github.com/sass/node-sass
107-
outputStyle: NODE_ENV === 'production' ? 'compressed' : 'expanded',
108-
includePaths: [
109-
'./frontend/sass-vendor/',
110-
'./node_modules/'
111-
],
126+
outputStyle: NODE_ENV === "production" ? "compressed" : "expanded",
127+
includePaths: ["./frontend/sass-vendor/", "./node_modules/"],
112128
precision: 5
113129
},
114130

115131
postcss_plugins: postcss_plugins,
116132

117133
livereload_options: {
118-
host: '127.0.0.1',
134+
host: "127.0.0.1",
119135
port: 35729
120136
},
121137

@@ -125,7 +141,15 @@ module.exports = {
125141
},
126142

127143
pngquant_options: {
128-
quality: '40-100',
144+
speed: 1,
145+
strip: true,
146+
quality: [0.65, 0.8],
129147
verbose: true
148+
},
149+
150+
webp_options: {
151+
// preset: "default",
152+
quality: 80,
153+
method: 6
130154
}
131155
};

src/frontend/gulp/tasks/clean.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
'use strict';
1+
"use strict";
22

3-
const gulp = require('gulp'),
4-
del = require('del'),
5-
config = require('../config');
3+
const gulp = require("gulp"),
4+
del = require("del"),
5+
config = require("../config");
66

77
function clean() {
88
// clean task
99
return del([
10-
config.paths.css + '*.css',
10+
config.paths.css + "*.css",
11+
config.paths.dist,
1112
config.paths.vendor,
12-
'!' + config.paths.css + 'user-styles.css'
13+
"!" + config.paths.css + "user-styles.css"
1314
]);
1415
}
1516

16-
gulp.task('clean', clean);
17+
gulp.task("clean", clean);
Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,43 @@
1-
const gulp = require('gulp'),
2-
plumber = require('gulp-plumber'),
3-
imagemin = require('gulp-imagemin'),
4-
imageminPngquant = require('imagemin-pngquant'),
5-
imageminMozjpeg = require('imagemin-mozjpeg'),
6-
config = require('../config');
1+
const gulp = require("gulp"),
2+
webp = require('gulp-webp'),
3+
merge = require("merge-stream"),
4+
plumber = require("gulp-plumber"),
5+
imagemin = require("gulp-imagemin"),
6+
imageminPngquant = require("imagemin-pngquant"),
7+
imageminMozjpeg = require("imagemin-mozjpeg"),
8+
size = require("gulp-size"),
9+
config = require("../config");
710

811
function minifyImages() {
9-
return gulp.src(config.paths.images + '**/*.{png,jpg,jpeg}')
12+
const pngs = gulp
13+
.src(config.paths.images + "**/*.png")
1014
.pipe(plumber())
11-
.pipe(imagemin({
12-
use: [
13-
imageminPngquant(config.pngquant_options),
14-
imageminMozjpeg(config.mozjpeg_options)
15-
]
16-
}))
17-
.pipe(gulp.dest(config.paths.images));
15+
.pipe(imagemin([imageminPngquant(config.pngquant_options)]))
16+
.pipe(size({ showFiles: true, showTotal: false }))
17+
.pipe(gulp.dest(config.paths.dist));
18+
19+
const jpegs = gulp
20+
.src(config.paths.images + "**/*.{jpg,jpeg}")
21+
.pipe(plumber())
22+
.pipe(imagemin([imageminMozjpeg(config.mozjpeg_options)]))
23+
.pipe(size({ showFiles: true, showTotal: false }))
24+
.pipe(gulp.dest(config.paths.dist));
25+
26+
const pngsToWebp = gulp
27+
.src(config.paths.images + "**/*.png")
28+
.pipe(plumber())
29+
.pipe(webp({lossless: true, ...config.webp_options}))
30+
.pipe(size({ showFiles: true, showTotal: false }))
31+
.pipe(gulp.dest(config.paths.dist));
32+
33+
const jpegsToWebp = gulp
34+
.src(config.paths.images + "**/*.{jpg,jpeg}")
35+
.pipe(plumber())
36+
.pipe(webp({lessless: false, ...config.webp_options}))
37+
.pipe(size({ showFiles: true, showTotal: false }))
38+
.pipe(gulp.dest(config.paths.dist));
39+
40+
return merge(pngs, jpegs, pngsToWebp, jpegsToWebp);
1841
}
1942

20-
gulp.task('imagemin', minifyImages);
43+
gulp.task("imagemin", minifyImages);

src/frontend/gulp/tasks/sass.js

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,62 @@
1-
'use strict';
2-
3-
const gulp = require('gulp'),
4-
filesExist = require('files-exist'),
5-
plumber = require('gulp-plumber'),
6-
gulpSass = require('gulp-sass'),
7-
sourcemaps = require('gulp-sourcemaps'),
8-
livereload = require('gulp-livereload'),
9-
postcss = require('gulp-postcss'),
10-
notify = require('gulp-notify'),
11-
size = require('gulp-size'),
12-
config = require('../config');
1+
"use strict";
2+
3+
const gulp = require("gulp"),
4+
filesExist = require("files-exist"),
5+
plumber = require("gulp-plumber"),
6+
gulpSass = require("gulp-sass")(require('node-sass')),
7+
sourcemaps = require("gulp-sourcemaps"),
8+
livereload = require("gulp-livereload"),
9+
postcss = require("gulp-postcss"),
10+
notify = require("gulp-notify"),
11+
size = require("gulp-size"),
12+
config = require("../config");
1313

1414
var NODE_ENV = process.env.NODE_ENV;
1515

16-
1716
function handleErrors() {
1817
var args = Array.prototype.slice.call(arguments);
18+
console.error(args);
1919

2020
// Alternative instead of default sass.logError
2121
// Send error to Mac notification center with gulp-notify:
22-
notify.onError({
23-
title: "Compile Error",
24-
message: "<%= error.message %>"
25-
}).apply(this, args);
26-
27-
this.emit('end');
22+
notify
23+
.onError({
24+
title: "Compile Error",
25+
message: "<%= error.message %>"
26+
})
27+
.apply(this, args);
28+
29+
this.emit("end");
2830
}
2931

30-
3132
function sass() {
3233
// Task to compile sass
33-
return gulp.src(filesExist(config.paths.sass_glob))
34-
.pipe(plumber({errorHandler: handleErrors}))
34+
return gulp
35+
.src(filesExist(config.paths.sass_glob))
36+
.pipe(plumber({ errorHandler: handleErrors }))
3537
.pipe(sourcemaps.init())
3638
.pipe(gulpSass(config.sass_options))
3739
.pipe(postcss(config.postcss_plugins))
38-
.pipe(sourcemaps.write('.'))
39-
.pipe(size({showFiles: true}))
40-
.pipe(gulp.dest(config.paths.css))
41-
.pipe(livereload())
40+
.pipe(sourcemaps.write("."))
41+
.pipe(size({ showFiles: true }))
42+
.pipe(gulp.dest(config.paths.dist))
43+
.pipe(livereload());
4244
}
4345

44-
4546
function sassWatch() {
4647
// Watch and recompile on changes
47-
return gulp.watch(config.paths.sass_glob, sass)
48-
.on('all', function (event, path, stats) {
49-
console.log('[watcher] File ' + path.replace(/.*(?=sass)/, '') + ' was ' + event + ', compiling...');
48+
return gulp
49+
.watch(config.paths.sass_glob, sass)
50+
.on("all", function(event, path, stats) {
51+
console.log(
52+
"[watcher] File " +
53+
path.replace(/.*(?=sass\/)/, "") +
54+
" was " +
55+
event +
56+
", compiling..."
57+
);
5058
});
5159
}
5260

53-
gulp.task('sass', sass);
54-
gulp.task('sass:watch', gulp.series(sass, sassWatch));
61+
gulp.task("sass", sass);
62+
gulp.task("sass:watch", gulp.series(sass, sassWatch));

src/frontend/gulp/tasks/sprite.js

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)