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

Unified Diff: gulpfile.js

Issue 29624561: Issue 6104 - Minified code in help center repository (Closed) Base URL: https://hg.adblockplus.org/help.eyeo.com
Patch Set: Created Nov. 29, 2017, 2:25 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« .gitignore ('K') | « .hgignore ('k') | package.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gulpfile.js
===================================================================
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -13,25 +13,77 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with help.eyeo.com. If not, see <http://www.gnu.org/licenses/>.
*/
const gulp = require('gulp');
const gutil = require('gulp-util');
+const sourcemaps = require('gulp-sourcemaps');
+const rename = require('gulp-rename');
+
+/**************************************************************************
+ * CSS
juliandoucette 2017/11/29 23:30:36 There seems to be something wrong with the SCSS so
ire 2017/11/30 10:04:43 Fixed. It was because I was calling sourcemaps.wri
+ **************************************************************************/
+
const sass = require('gulp-sass');
const postcss = require('gulp-postcss');
const scss = require('postcss-scss');
const autoprefixer = require('autoprefixer');
+const cleanCSS = require('gulp-clean-css');
gulp.task('css', function() {
- return gulp.src('./static/scss/main.scss')
+ return gulp.src('./src/scss/main.scss')
+ .pipe(sourcemaps.init())
.pipe(postcss([autoprefixer()], {syntax: scss}).on('error', gutil.log))
.pipe(sass().on('error', gutil.log))
+ .pipe(sourcemaps.write('./'))
+ .pipe(gulp.dest('./static/css'))
+ .pipe(cleanCSS())
+ .pipe(rename('main.min.css'))
+ .pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./static/css'));
});
-gulp.task('watch', function() {
- gulp.watch('./static/scss/**/*.scss', ['css']);
+/**************************************************************************
+ * JS
+ **************************************************************************/
+
+const minify = require('gulp-minify');
juliandoucette 2017/11/29 23:30:36 Requires usually go at the top
ire 2017/11/30 10:04:43 Is that a coding style thing? I thought it made se
juliandoucette 2017/12/04 10:49:37 "<kzar> julian: Yea. It's certainly a convention t
+
+gulp.task('js', function() {
+ return gulp.src(['./src/js/*.js'])
+ .pipe(sourcemaps.init())
+ .pipe(minify({
+ ext: {src:'.js', min:'.min.js'},
+ preserveComments: 'some'
+ }))
+ .pipe(sourcemaps.write('./'))
+ .pipe(gulp.dest('./static/js'))
});
-gulp.task('default', ['css', 'watch']);
+gulp.task('js-vendor', function() {
+ return gulp.src(['./src/js/vendor/*.js'])
+ .pipe(sourcemaps.init())
+ .pipe(minify({
+ ext: {src:'.js', min:'.min.js'},
+ preserveComments: 'some'
+ }))
+ .pipe(sourcemaps.write('./'))
+ .pipe(gulp.dest('./static/js/vendor'))
+});
+
+/**************************************************************************
+ * Watch
+ **************************************************************************/
+
+gulp.task('watch', function() {
+ gulp.watch('./src/scss/**/*.scss', ['css']);
+ gulp.watch('./src/js/*.js', ['js']);
+ gulp.watch('./src/js/vendor/*.js', ['js-vendor']);
+});
+
+/**************************************************************************
+ * Default
+ **************************************************************************/
+
+gulp.task('default', ['css', 'js', 'js-vendor', 'watch']);
« .gitignore ('K') | « .hgignore ('k') | package.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld