12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- /**
- * @Author: Bachir Soussi Chiadmi <bach>
- * @Date: 20-12-2017
- * @Email: bachir@figureslibres.io
- * @Filename: gulpfile.js
- * @Last modified by: bach
- * @Last modified time: 20-12-2017
- * @License: GPL-V3
- */
- 'use strict';
- var gulp = require('gulp');
- var gulpif = require('gulp-if');
- var sass = require('gulp-sass');
- var watch = require('gulp-watch');
- var autoprefixer = require('gulp-autoprefixer');
- var stripDebug = require('gulp-strip-debug');
- var jsmin = require('gulp-jsmin');
- var cssmin = require('gulp-cssmin');
- var rename = require('gulp-rename');
- // var mainBowerFiles = require('main-bower-files');
- var es = require('event-stream');
- var modules = ['edlp_corpus', 'edlp_studio', 'edlp_search'];
- // to get minified assets run `gulp --env=prod`
- var argv = require('minimist')(process.argv.slice(2));
- console.dir(argv);
- var prod = argv.env == 'prod' ? true : false;
- function handleError(err) {
- console.log(err.toString());
- }
- gulp.task('scripts', function () {
- var tasks = modules.map(function(module) {
- return gulp.src('./'+module+'/assets/scripts/*.js')
- .pipe(gulpif(prod, stripDebug()))
- .pipe(gulpif(prod, jsmin()))
- .pipe(rename({suffix: '.min'}))
- .pipe(gulp.dest('./'+module+'/assets/dist/scripts/'));
- });
- return es.merge.apply(null, tasks);
- });
- gulp.task('styles', function () {
- var tasks = modules.map(function(module) {
- return gulp.src('./'+module+'/assets/styles/*.scss')
- .pipe(sass().on('error', sass.logError))
- .pipe(autoprefixer({
- browsers: ['last 2 versions'],
- cascade: false
- })).on('error', handleError)
- .pipe(gulpif(prod, cssmin()))
- // .pipe(cssmin())
- .pipe(rename({suffix: '.min'}))
- .pipe(gulp.dest('./'+module+'/assets/dist/styles/'));
- });
- return es.merge.apply(null, tasks);
- });
- // default gulp task
- gulp.task('default', ['scripts', 'styles'], function() { //'bower',
- for (var i = 0; i < modules.length; i++) {
- // gulp.watch('./assets/styles/*/*.scss', ['styles']);
- gulp.watch('./'+modules[i]+'/assets/styles/*.scss', ['styles']);
- gulp.watch('./'+modules[i]+'/assets/scripts/*.js', ['scripts']);
- }
- });
|