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: Fix sourcemaps for CSS files, Change tabs to spaces Created Nov. 30, 2017, 10:03 a.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
« no previous file with comments | « .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,93 @@
* 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
+ ******************************************************************************/
+
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')
- .pipe(postcss([autoprefixer()], {syntax: scss}).on('error', gutil.log))
- .pipe(sass().on('error', gutil.log))
- .pipe(gulp.dest('./static/css'));
+const entryScssFile = 'main';
+
+gulp.task('css', ['css-default', 'css-minified']);
+
+/* Expanded CSS
+ ******************************************************************************/
+
+gulp.task('css-default', function() {
+ return gulp.src(`./src/scss/${entryScssFile}.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'))
+});
+
+/* Minified CSS
+ ******************************************************************************/
+
+gulp.task('css-minified', function() {
+ return gulp.src(`./src/scss/${entryScssFile}.scss`)
+ .pipe(sourcemaps.init())
+ .pipe(postcss([autoprefixer()], {syntax: scss}).on('error', gutil.log))
+ .pipe(sass({outputStyle: 'compressed'}).on('error', gutil.log))
+ .pipe(rename(`${entryScssFile}.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');
+
+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']);
« no previous file with comments | « .hgignore ('k') | package.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld