123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- '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 jsmin = require('gulp-jsmin');
- var stripDebug = require('gulp-strip-debug');
- var cssmin = require('gulp-cssmin');
- var rename = require('gulp-rename');
- var mainBowerFiles = require('main-bower-files');
- // var jsonToSass = require('gulp-json-to-sass');
- // var concat = require('gulp-concat');
- var svgmin = require('gulp-svgmin');
- // var fs = require('fs');
- // var json2js = require('gulp-json2js');
- // var data = require('gulp-data');
- // var shared_variables = JSON.parse(fs.readFileSync('./assets/json/shared_variables.json'));
- // 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 () {
- gulp.src(['./assets/scripts/main.js', './assets/scripts/history.js']) // './assets/scripts/shared_variables.js',
- // .pipe(concat('main.js'))
- .pipe(gulpif(prod, stripDebug()))
- .pipe(gulpif(prod, jsmin()))
- .pipe(rename({suffix: '.min'}))
- .pipe(gulp.dest('./assets/dist/scripts/'));
- });
- gulp.task('styles', function () {
- gulp.src(['./assets/styles/app.scss'])
- .pipe(sass().on('error', sass.logError))
- .pipe(autoprefixer({
- browsers: ['last 2 versions'],
- cascade: false
- })).on('error', handleError)
- // .pipe(prod ? cssmin() : util.noop())
- .pipe(gulpif(prod, cssmin()))
- // .pipe(cssmin())
- .pipe(rename({suffix: '.min'}))
- .pipe(gulp.dest('./assets/dist/styles/'));
- });
- gulp.task('bower', function() {
- gulp.src(mainBowerFiles({
- "overrides":{
- "masonry-layout":{
- "main":"./dist/masonry.pkgd.min.js"
- },
- "imagesloaded":{
- "main":"./imagesloaded.pkgd.min.js"
- },
- "jquery":{"ignore":true},
- "ev-emitter":{"ignore":true},
- "fizzy-ui-utils":{"ignore":true},
- "get-size":{"ignore":true},
- "outlayer":{"ignore":true},
- }
- }))
- .pipe(gulp.dest('./assets/dist/bower/'));
- });
- gulp.task('svg', function () {
- gulp.src(['./assets/img/*.svg', '!./assets/img/edlp-loader-anim.svg'])
- .pipe(svgmin())
- .pipe(gulp.dest('./assets/dist/img'));
- gulp.src('./assets/img/edlp-loader-anim.svg')
- .pipe(gulp.dest('./assets/dist/img'));
- });
- // default gulp task
- // , 'vars2sass' 'vars2js',
- gulp.task('default', ['bower', 'scripts', 'styles', 'svg'], function() {
- // gulp.watch('./assets/json/*.json', ['vars2js', 'styles', 'scripts']); //, 'vars2sass'
- gulp.watch('./assets/styles/*.scss', ['styles']);
- gulp.watch('./assets/styles/base/*.scss', ['styles']);
- gulp.watch('./assets/scripts/*.js', ['scripts']);
- gulp.watch('./assets/img/*.svg', ['svg']);
- });
- // this task stays here just for memeomry about how to share variables between js and css
- // gulp.task('vars2sass', function () {
- // gulp.src('./assets/json/shared_variables.json')
- // .pipe(jsonToSass({
- // jsonPath: './assets/json/shared_variables.json',
- // scssPath: './assets/styles/base/_shared_variables.scss'
- // }));
- // });
- // this one is not working, works first run but then it's like it's caching the source
- // gulp.task('variables2js', function() {
- // gulp.src('./assets/scripts/shared_variables_model.js')
- // .pipe(rename('shared_variables.js'))
- // .pipe(data(function(file) {
- // delete require.cache['./assets/json/shared_variables.json'];
- // return require('./assets/json/shared_variables.json');
- // }))
- // .pipe(json2js())
- // .pipe(gulp.dest('./assets/scripts/'));
- // });
- // gulp.task('vars2js', function() {
- // gulp.src('./assets/json/shared_variables.json')
- // .pipe(rename('shared_variables.js'))
- // .pipe(through.obj(function (file, enc, cb) {
- // // console.log('file',String(file.contents));
- // // small pipe to wrappe json data into a js variable
- // file.contents = new Buffer("edlp_vars = "+String(file.contents).trim()+";");
- // cb(null, file);
- // }))
- // .pipe(gulp.dest('./assets/scripts/'));
- // });
|