1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- /**
- * @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';
- import gulp from 'gulp';
- const { series, src, dest, watch } = gulp;
- import gulpif from 'gulp-if';
- import * as dartSass from 'sass';
- import gulpSass from 'gulp-sass';
- const sass = gulpSass(dartSass);
- import autoprefixer from 'gulp-autoprefixer';
- import stripDebug from 'gulp-strip-debug';
- import jsmin from 'gulp-jsmin';
- import cssmin from 'gulp-cssmin';
- import rename from 'gulp-rename';
- import minimist from 'minimist';
- // var es = require('event-stream');
- var modules = ['edlp_corpus', 'edlp_studio', 'edlp_search'];
- // to get minified assets run `gulp --env=prod`
- var argv = minimist(process.argv.slice(2));
- console.dir(argv);
- var prod = argv.env == 'prod' ? true : false;
- function handleError(err) {
- console.log(err.toString());
- }
- function scripts() {
- return new Promise(function(resolve, reject) {
- modules.map(function(module) {
- 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();
- });
- };
- function styles() {
- return new Promise(function(resolve, reject) {
- modules.map(function(module) {
- 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
- function defaultTask () {
- series('scripts', 'styles', done => {
- for (var i = 0; i < modules.length; i++) {
- watch('./'+modules[i]+'/assets/styles/*.scss', series('styles'));
- watch('./'+modules[i]+'/assets/scripts/*.js', series('scripts'));
- }
- done()
- })
- };
- function devwatch(){
- watch('./assets/styles/*.scss', series('styles'));
- watch('./assets/styles/base/*.scss', series('styles'));
- watch('./assets/scripts/*.js', series('scripts'));
- }
- export {
- scripts as scripts,
- styles as styles,
- devwatch as devwatch,
- defaultTask as default
- }
|