Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: gulpfile.js

Issue 29624561: Issue 6104 - Minified code in help center repository (Closed) Base URL: https://hg.adblockplus.org/help.eyeo.com
Left Patch Set: Fix sourcemaps for CSS files, Change tabs to spaces Created Nov. 30, 2017, 10:03 a.m.
Right Patch Set: Consolidated gulp tasks Created Dec. 7, 2017, 2:48 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « globals/get_inline_bg.py ('k') | includes/layout/header.tmpl » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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');
24 const postcss = require('gulp-postcss');
25 const scss = require('postcss-scss');
26 const autoprefixer = require('autoprefixer');
27 const minify = require('gulp-minify');
23 28
24 /****************************************************************************** 29 /******************************************************************************
25 * CSS 30 * CSS
26 ******************************************************************************/ 31 ******************************************************************************/
27 32
28 const sass = require('gulp-sass'); 33 gulp.task('css', function() {
juliandoucette 2017/12/08 14:57:21 Single quotes :( ... (I love single quotes... I w
ire 2017/12/11 15:29:31 Done.
29 const postcss = require('gulp-postcss'); 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.
30 const scss = require('postcss-scss');
31 const autoprefixer = require('autoprefixer');
32 const cleanCSS = require('gulp-clean-css');
33
34 const entryScssFile = 'main';
35
36 gulp.task('css', ['css-default', 'css-minified']);
37
38 /* Expanded CSS
39 ******************************************************************************/
40
41 gulp.task('css-default', function() {
42 return gulp.src(`./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/css'))
48 });
49
50 /* Minified CSS
51 ******************************************************************************/
52
53 gulp.task('css-minified', function() {
54 return gulp.src(`./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/css')); 40 .pipe(gulp.dest('./static/dist/css'));
61 }); 41 });
62 42
63 /****************************************************************************** 43 /******************************************************************************
64 * JS 44 * JS
65 ******************************************************************************/ 45 ******************************************************************************/
66 46
67 const minify = require('gulp-minify');
68
69 gulp.task('js', function() { 47 gulp.task('js', function() {
70 return gulp.src(['./src/js/*.js']) 48 return gulp.src(['./static/src/js/**/*.js'])
71 .pipe(sourcemaps.init()) 49 .pipe(sourcemaps.init())
72 .pipe(minify({ 50 .pipe(minify({
51 noSource: true,
73 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.
74 preserveComments: 'some' 53 preserveComments: 'some'
75 })) 54 }))
76 .pipe(sourcemaps.write('./')) 55 .pipe(sourcemaps.write('./'))
77 .pipe(gulp.dest('./static/js')) 56 .pipe(gulp.dest('./static/dist/js'))
78 });
79
80 gulp.task('js-vendor', function() {
81 return gulp.src(['./src/js/vendor/*.js'])
82 .pipe(sourcemaps.init())
83 .pipe(minify({
84 ext: {src:'.js', min:'.min.js'},
85 preserveComments: 'some'
86 }))
87 .pipe(sourcemaps.write('./'))
88 .pipe(gulp.dest('./static/js/vendor'))
89 }); 57 });
90 58
91 /****************************************************************************** 59 /******************************************************************************
92 * Watch 60 * Watch
93 ******************************************************************************/ 61 ******************************************************************************/
94 62
95 gulp.task('watch', function() { 63 gulp.task('watch', function() {
96 gulp.watch('./src/scss/**/*.scss', ['css']); 64 gulp.watch('./static/src/scss/**/*.scss', ['css']);
97 gulp.watch('./src/js/*.js', ['js']); 65 gulp.watch('./static/src/js/**/*.js', ['js']);
98 gulp.watch('./src/js/vendor/*.js', ['js-vendor']);
99 }); 66 });
100 67
101 /****************************************************************************** 68 /******************************************************************************
102 * Default 69 * Default
103 ******************************************************************************/ 70 ******************************************************************************/
104 71
105 gulp.task('default', ['css', 'js', 'js-vendor', 'watch']); 72 gulp.task('default', ['css', 'js', 'watch']);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld