123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- '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 = [
- {
- modname:'edlp_studio',
- srcjs:['./edlp_studio/assets/scripts/edlp_studio.js']
- },
- {
- modname:'edlp_search',
- srcjs:['./edlp_search/assets/scripts/edlp_search.js']
- },
- {
- modname:'edlp_corpus',
- srcjs:['./edlp_corpus/assets/scripts/corpus.js', './edlp_corpus/assets/scripts/physics.js'],
- srccss:['./edlp_corpus/assets/styles/corpus.scss']
- }];
- // 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) {
- // console.log('module', module);
-
- src(module.srcjs, {allowEmpty: true})
- .on('data', function(file) {
- console.log('File src:', file.path);
- })
- .pipe(gulpif(prod, stripDebug()))
- .pipe(gulpif(prod, jsmin()))
- .pipe(rename({suffix: '.min'}))
- .pipe(dest(`./${module.modname}/assets/dist/scripts/`));
- // .on('data', function(file) {
- // console.log('File dest:', file.path);
- // });
- });
- resolve();
- });
- // return src(['./edlp_studio/assets/scripts/edlp_studio.js'])
- // .pipe(gulpif(prod, stripDebug()))
- // .pipe(gulpif(prod, jsmin()))
- // .pipe(rename({suffix: '.min'}))
- // .pipe(dest('./edlp_studio/assets/dist/scripts/'));
- };
- function styles() {
- return new Promise(function(resolve, reject) {
- modules.map(function(module) {
- if (module.srccss) {
- src(module.srccss, {allowEmpty: true})
- .pipe(sass().on('error', sass.logError))
- .pipe(autoprefixer({
- cascade: false
- })).on('error', handleError)
- .pipe(gulpif(prod, cssmin()))
- // .pipe(cssmin())
- .pipe(rename({suffix: '.min'}))
- .pipe(dest('./'+module.modname+'/assets/dist/styles/'));
- }
- });
- resolve();
- });
- // return src('./edlp_studio/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(dest('./edlp_studio/assets/dist/styles/'));
- };
- // default gulp task
- function devwatch () {
- // series(scripts, styles, done => {
- for (var i = 0; i < modules.length; i++) {
- watch('./'+modules[i].modname+'/assets/styles/*.scss', styles);
- watch('./'+modules[i].modname+'/assets/scripts/*.js', scripts);
- }
- // done()
- // })
- };
- export default series(scripts, styles); //
- export { devwatch }
|