Left: | ||
Right: |
OLD | NEW |
---|---|
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'); | |
22 const rename = require('gulp-rename'); | |
21 const sass = require('gulp-sass'); | 23 const sass = require('gulp-sass'); |
22 const postcss = require('gulp-postcss'); | 24 const postcss = require('gulp-postcss'); |
23 const scss = require('postcss-scss'); | 25 const scss = require('postcss-scss'); |
24 const autoprefixer = require('autoprefixer'); | 26 const autoprefixer = require('autoprefixer'); |
27 const cleanCSS = require('gulp-clean-css'); | |
28 const minify = require('gulp-minify'); | |
25 | 29 |
26 gulp.task('css', function() { | 30 /****************************************************************************** |
27 return gulp.src('./static/scss/main.scss') | 31 * CSS |
28 » » .pipe(postcss([autoprefixer()], {syntax: scss}).on('error', guti l.log)) | 32 ******************************************************************************/ |
29 » » .pipe(sass().on('error', gutil.log)) | 33 |
30 » » .pipe(gulp.dest('./static/css')); | 34 const entryScssFile = 'main'; |
juliandoucette
2017/12/06 15:01:36
NIT: Discussed in-person. I think this is unnecess
ire
2017/12/07 14:54:18
Done.
| |
35 | |
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')) | |
31 }); | 48 }); |
32 | 49 |
33 gulp.task('watch', function() { | 50 /* Minified CSS |
34 gulp.watch('./static/scss/**/*.scss', ['css']); | 51 ******************************************************************************/ |
52 | |
53 gulp.task('css-minified', function() { | |
54 return gulp.src(`./static/src/scss/${entryScssFile}.scss`) | |
55 .pipe(sourcemaps.init()) | |
56 .pipe(postcss([autoprefixer()], {syntax: scss}).on('error', gutil.log)) | |
57 .pipe(sass({outputStyle: 'compressed'}).on('error', gutil.log)) | |
58 .pipe(rename(`${entryScssFile}.min.css`)) | |
59 .pipe(sourcemaps.write('./')) | |
60 .pipe(gulp.dest('./static/dist/css')); | |
35 }); | 61 }); |
36 | 62 |
37 gulp.task('default', ['css', 'watch']); | 63 /****************************************************************************** |
64 * JS | |
65 ******************************************************************************/ | |
66 | |
67 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']) | |
69 .pipe(sourcemaps.init()) | |
70 .pipe(minify({ | |
71 ext: {src:'.js', min:'.min.js'}, | |
72 preserveComments: 'some' | |
73 })) | |
74 .pipe(sourcemaps.write('./')) | |
75 .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 }); | |
88 | |
89 /****************************************************************************** | |
90 * Watch | |
91 ******************************************************************************/ | |
92 | |
93 gulp.task('watch', function() { | |
94 gulp.watch('./static/src/scss/**/*.scss', ['css']); | |
95 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 }); | |
98 | |
99 /****************************************************************************** | |
100 * Default | |
101 ******************************************************************************/ | |
102 | |
103 gulp.task('default', ['css', 'js', 'js-vendor', 'watch']); | |
OLD | NEW |