12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- /**
- * @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 (done) {
- return new Promise(function(resolve, reject) {
- modules.map(function(module) {
- 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/'));
- });
- resolve();
- });
- });
- gulp.task('styles', function (done) {
- return new Promise(function(resolve, reject) {
- modules.map(function(module) {
- gulp.src('./'+module+'/assets/styles/*.scss')
- .pipe(sass().on('error', sass.logError))
- .pipe(autoprefixer({
- cascade: false
- })).on('error', handleError)
- .pipe(gulpif(prod, cssmin()))
- // .pipe(cssmin())
- .pipe(rename({suffix: '.min'}))
- .pipe(gulp.dest('./'+module+'/assets/dist/styles/'));
- });
- resolve();
- });
- });
- // default gulp task
- gulp.task('default', gulp.series('scripts', 'styles', done => {
- for (var i = 0; i < modules.length; i++) {
- gulp.watch('./'+modules[i]+'/assets/styles/*.scss', gulp.series('styles'));
- gulp.watch('./'+modules[i]+'/assets/scripts/*.js', gulp.series('scripts'));
- }
- done()
- }));
|