Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /*! | 1 /*! |
2 * This file is part of help.eyeo.com. | 2 * This file is part of help.eyeo.com. |
3 * Copyright (C) 2017-present eyeo GmbH | 3 * Copyright (C) 2017-present eyeo GmbH |
4 * | 4 * |
5 * help.eyeo.com is free software: you can redistribute it and/or modify | 5 * help.eyeo.com is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License as published by | 6 * it under the terms of the GNU General Public License as published by |
7 * the Free Software Foundation, either version 3 of the License, or | 7 * the Free Software Foundation, either version 3 of the License, or |
8 * (at your option) any later version. | 8 * (at your option) any later version. |
9 * | 9 * |
10 * help.eyeo.com is distributed in the hope that it will be useful, | 10 * help.eyeo.com is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 * GNU General Public License for more details. | 13 * GNU General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU General Public License | 15 * You should have received a copy of the GNU General Public License |
16 * along with help.eyeo.com. If not, see <http://www.gnu.org/licenses/>. | 16 * along with help.eyeo.com. If not, see <http://www.gnu.org/licenses/>. |
17 */ | 17 */ |
18 | 18 |
19 const gulp = require('gulp'); | 19 const gulp = require('gulp'); |
20 const gutil = require('gulp-util'); | 20 const gutil = require('gulp-util'); |
21 const sourcemaps = require('gulp-sourcemaps'); | 21 const sourcemaps = require('gulp-sourcemaps'); |
22 const rename = require('gulp-rename'); | 22 const rename = require('gulp-rename'); |
23 const sass = require('gulp-sass'); | 23 const sass = require('gulp-sass'); |
24 const postcss = require('gulp-postcss'); | 24 const postcss = require('gulp-postcss'); |
25 const scss = require('postcss-scss'); | 25 const scss = require('postcss-scss'); |
26 const autoprefixer = require('autoprefixer'); | 26 const autoprefixer = require('autoprefixer'); |
27 const cleanCSS = require('gulp-clean-css'); | |
28 const minify = require('gulp-minify'); | 27 const minify = require('gulp-minify'); |
29 | 28 |
30 /****************************************************************************** | 29 /****************************************************************************** |
31 * CSS | 30 * CSS |
32 ******************************************************************************/ | 31 ******************************************************************************/ |
33 | 32 |
34 const entryScssFile = 'main'; | 33 gulp.task('css', function() { |
juliandoucette
2017/12/06 15:01:36
NIT: Discussed in-person. I think this is unnecess
ire
2017/12/07 14:54:18
Done.
|
juliandoucette
2017/12/08 14:57:21
Single quotes :( ...
(I love single quotes... I w
ire
2017/12/11 15:29:31
Done.
|
35 | 34 return gulp.src(`./static/src/scss/main.scss`) |
juliandoucette
2017/12/08 14:57:17
Backtics...
ire
2017/12/11 15:29:32
Done.
| |
36 gulp.task('css', ['css-default', 'css-minified']); | |
37 | |
38 /* Expanded CSS | |
juliandoucette
2017/12/06 15:01:36
NIT: It seems like this comment describes the task
ire
2017/12/07 14:54:23
Ack. This isn't necessary anymore since we are onl
| |
39 ******************************************************************************/ | |
40 | |
41 gulp.task('css-default', function() { | |
juliandoucette
2017/12/06 15:01:35
I don't think that it's necessary to output both m
ire
2017/12/07 14:54:19
Done.
| |
42 return gulp.src(`./static/src/scss/${entryScssFile}.scss`) | |
43 .pipe(sourcemaps.init()) | |
44 .pipe(postcss([autoprefixer()], {syntax: scss}).on('error', gutil.log)) | |
45 .pipe(sass().on('error', gutil.log)) | |
46 .pipe(sourcemaps.write('./')) | |
47 .pipe(gulp.dest('./static/dist/css')) | |
48 }); | |
49 | |
50 /* Minified CSS | |
51 ******************************************************************************/ | |
52 | |
53 gulp.task('css-minified', function() { | |
54 return gulp.src(`./static/src/scss/${entryScssFile}.scss`) | |
55 .pipe(sourcemaps.init()) | 35 .pipe(sourcemaps.init()) |
56 .pipe(postcss([autoprefixer()], {syntax: scss}).on('error', gutil.log)) | 36 .pipe(postcss([autoprefixer()], {syntax: scss}).on('error', gutil.log)) |
57 .pipe(sass({outputStyle: 'compressed'}).on('error', gutil.log)) | 37 .pipe(sass({outputStyle: 'compressed'}).on('error', gutil.log)) |
58 .pipe(rename(`${entryScssFile}.min.css`)) | 38 .pipe(rename(`main.min.css`)) |
59 .pipe(sourcemaps.write('./')) | 39 .pipe(sourcemaps.write('./')) |
60 .pipe(gulp.dest('./static/dist/css')); | 40 .pipe(gulp.dest('./static/dist/css')); |
61 }); | 41 }); |
62 | 42 |
63 /****************************************************************************** | 43 /****************************************************************************** |
64 * JS | 44 * JS |
65 ******************************************************************************/ | 45 ******************************************************************************/ |
66 | 46 |
67 gulp.task('js', function() { | 47 gulp.task('js', function() { |
juliandoucette
2017/12/06 15:01:34
It seems like we should be able to combine the src
ire
2017/12/07 14:54:20
You're right. I didn't think it would preserve the
| |
68 return gulp.src(['./static/src/js/*.js']) | 48 return gulp.src(['./static/src/js/**/*.js']) |
69 .pipe(sourcemaps.init()) | 49 .pipe(sourcemaps.init()) |
70 .pipe(minify({ | 50 .pipe(minify({ |
51 noSource: true, | |
71 ext: {src:'.js', min:'.min.js'}, | 52 ext: {src:'.js', min:'.min.js'}, |
juliandoucette
2017/12/08 14:57:17
Maybe src:js is unnecessary?
ire
2017/12/11 15:29:31
Done.
| |
72 preserveComments: 'some' | 53 preserveComments: 'some' |
73 })) | 54 })) |
74 .pipe(sourcemaps.write('./')) | 55 .pipe(sourcemaps.write('./')) |
75 .pipe(gulp.dest('./static/dist/js')) | 56 .pipe(gulp.dest('./static/dist/js')) |
76 }); | |
77 | |
78 gulp.task('js-vendor', function() { | |
79 return gulp.src(['./static/src/js/vendor/*.js']) | |
80 .pipe(sourcemaps.init()) | |
81 .pipe(minify({ | |
82 ext: {src:'.js', min:'.min.js'}, | |
83 preserveComments: 'some' | |
84 })) | |
85 .pipe(sourcemaps.write('./')) | |
86 .pipe(gulp.dest('./static/dist/js/vendor')) | |
87 }); | 57 }); |
88 | 58 |
89 /****************************************************************************** | 59 /****************************************************************************** |
90 * Watch | 60 * Watch |
91 ******************************************************************************/ | 61 ******************************************************************************/ |
92 | 62 |
93 gulp.task('watch', function() { | 63 gulp.task('watch', function() { |
94 gulp.watch('./static/src/scss/**/*.scss', ['css']); | 64 gulp.watch('./static/src/scss/**/*.scss', ['css']); |
95 gulp.watch('./static/src/js/*.js', ['js']); | 65 gulp.watch('./static/src/js/**/*.js', ['js']); |
juliandoucette
2017/12/06 15:01:35
You could watch './static/src/js/**/*.js' instead
ire
2017/12/07 14:54:22
Done.
| |
96 gulp.watch('./static/src/js/vendor/*.js', ['js-vendor']); | |
97 }); | 66 }); |
98 | 67 |
99 /****************************************************************************** | 68 /****************************************************************************** |
100 * Default | 69 * Default |
101 ******************************************************************************/ | 70 ******************************************************************************/ |
102 | 71 |
103 gulp.task('default', ['css', 'js', 'js-vendor', 'watch']); | 72 gulp.task('default', ['css', 'js', 'watch']); |
LEFT | RIGHT |