moschino-ccss16
Version:
Moschino's Capsule Collection Spring Summer 2016 package
382 lines (366 loc) • 8.44 kB
JavaScript
;
var baseUrl = 'http://localhost/moschino/cc_ss16',
gulp = require('gulp'),
requirejsOptimize = require('gulp-requirejs'),
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
minifyCss = require('gulp-minify-css'),
minifyHTML = require('gulp-minify-html'),
livereload = require('gulp-livereload'),
del = require('del'),
print = require('gulp-print');
gulp.task('cleancss', function(cb) {
del(['build/css'], function (err, paths) {
console.log('Deleted files/folders:\n', paths.join('\n') );
});
});
gulp.task('cleanjs', function(cb) {
del(['build/js'], function (err, paths) {
console.log('Deleted files/folders:\n', paths.join('\n') );
});
});
gulp.task('sass', function() {
gulp.src(['./dev/css/*.scss', '!./dev/css/_*.scss'])
.pipe(sass({ errLogToConsole: true, sync: true }))
.pipe(minifyCss({aggressiveMerging: false, keepSpecialComments: false, shorthandCompacting: true}))
.pipe(gulp.dest('./build/css'))
.pipe( print('Generated CSS file') );
livereload.changed(baseUrl+'/index.html', 80);
});
gulp.task('scripts-dev', function() {
requirejsOptimize({
baseUrl: './dev/js/',
name: 'bootstrap-dev',
out: 'app.js',
urlArgs : "v=" + (new Date()).getTime(),
waitSeconds: 60,
normalizeDirDefines: 'all',
preserveLicenseComments: false,
paths: {
jquery: 'framework/jquery',
tweenmax: 'framework/TweenMax',
handlebars: 'framework/handlebars',
iscroll: 'plugins/iscroll',
dragdealer: 'plugins/dragdealer',
isotope: 'plugins/isotope',
bridget: 'plugins/jquery.bridget',
router: 'plugins/director',
mobileevents: 'plugins/jquery.mobile-events',
easing: 'plugins/easing',
external: 'plugins/external',
browser: 'plugins/browser',
fastreg: 'plugins/jquery.fastreg',
panzoom: 'plugins/jquery.panzoom',
looks: '../../static/js/contents/looks',
gallery: '../../static/js/contents/gallery',
GlobalView: 'views/GlobalView',
TeaserView: 'views/TeaserView',
RouterView: 'views/RouterView',
LiveView: 'views/LiveView',
LiveLooksView: 'views/LiveLooksView',
LiveLooksDetailView: 'views/LiveLooksDetailView',
LiveItemsView: 'views/LiveItemsView',
LiveFashionView: 'views/LiveFashionView',
LiveSocialView: 'views/LiveSocialView'
},
shim : {
'easing' : {
deps : [
'jquery'
]
},
'external' : {
deps : [
'jquery'
]
},
'browser' : {
deps : [
'jquery'
]
},
'dragdealer' : {
deps : [
'jquery'
]
},
'iscroll' : {
exports : 'IScroll'
},
'isotope' : {
deps : [
'jquery'
]
},
'panzoom' : {
deps : [
'jquery'
]
},
'router' : {
exports : 'Router'
},
'bridget' : {
deps : [
'jquery'
]
},
'mobileevents' : {
deps : [
'jquery'
]
},
'fastreg' : {
deps : [
'jquery'
]
},
'tweenmax' : {
exports : 'TweenMax'
},
'handlebars' : {
exports : 'Handlebars'
},
'GlobalView' : {
deps : [
'TeaserView',
'LiveView'
]
},
'LiveView' : {
deps : [
'looks',
'gallery',
'router',
'RouterView',
'LiveLooksView',
'LiveLooksDetailView',
'LiveItemsView',
'LiveFashionView',
'LiveSocialView'
]
},
'LiveLooksView' : {
deps : [
'looks'
]
},
'LiveLooksDetailView' : {
deps : [
'looks',
'panzoom'
]
},
'LiveItemsView' : {
deps : [
'looks'
]
},
'LiveFashionView' : {
deps : [
'gallery',
'dragdealer'
]
}
}
})
.pipe(uglify())
.pipe(gulp.dest('./build/js'))
.pipe( print('Generated DEV JS file') );
});
gulp.task('scripts', function() {
requirejsOptimize({
baseUrl: './dev/js/',
name: 'bootstrap',
out: 'app.js',
urlArgs : "v=" + (new Date()).getTime(),
waitSeconds: 60,
normalizeDirDefines: 'all',
preserveLicenseComments: false,
paths: {
jquery: 'framework/jquery',
tweenmax: 'framework/TweenMax',
handlebars: 'framework/handlebars',
iscroll: 'plugins/iscroll',
dragdealer: 'plugins/dragdealer',
isotope: 'plugins/isotope',
bridget: 'plugins/jquery.bridget',
router: 'plugins/director',
mobileevents: 'plugins/jquery.mobile-events',
easing: 'plugins/easing',
external: 'plugins/external',
browser: 'plugins/browser',
fastreg: 'plugins/jquery.fastreg',
panzoom: 'plugins/jquery.panzoom',
looks: '../../static/js/contents/looks',
gallery: '../../static/js/contents/gallery',
GlobalView: 'views/GlobalView',
TeaserView: 'views/TeaserView',
RouterView: 'views/RouterView',
LiveView: 'views/LiveView',
LiveLooksView: 'views/LiveLooksView',
LiveLooksDetailView: 'views/LiveLooksDetailView',
LiveItemsView: 'views/LiveItemsView',
LiveFashionView: 'views/LiveFashionView',
LiveSocialView: 'views/LiveSocialView'
},
shim : {
'easing' : {
deps : [
'jquery'
]
},
'external' : {
deps : [
'jquery'
]
},
'browser' : {
deps : [
'jquery'
]
},
'dragdealer' : {
deps : [
'jquery'
]
},
'iscroll' : {
exports : 'IScroll'
},
'isotope' : {
deps : [
'jquery'
]
},
'panzoom' : {
deps : [
'jquery'
]
},
'router' : {
exports : 'Router'
},
'bridget' : {
deps : [
'jquery'
]
},
'mobileevents' : {
deps : [
'jquery'
]
},
'fastreg' : {
deps : [
'jquery'
]
},
'tweenmax' : {
exports : 'TweenMax'
},
'handlebars' : {
exports : 'Handlebars'
},
'GlobalView' : {
deps : [
'TeaserView',
'LiveView'
]
},
'LiveView' : {
deps : [
'looks',
'gallery',
'router',
'RouterView',
'LiveLooksView',
'LiveLooksDetailView',
'LiveItemsView',
'LiveFashionView',
'LiveSocialView'
]
},
'LiveLooksView' : {
deps : [
'looks'
]
},
'LiveLooksDetailView' : {
deps : [
'looks',
'panzoom'
]
},
'LiveItemsView' : {
deps : [
'looks'
]
},
'LiveFashionView' : {
deps : [
'gallery',
'dragdealer'
]
}
}
})
.pipe(uglify())
.pipe(gulp.dest('./build/js'))
.pipe( print('Generated PROD JS file') );
});
gulp.task('lint', function() {
return gulp.src('./dev/js/views/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('minify-html-dev', function() {
var opts = {
conditionals: true,
spare:true
};
return gulp.src('./dev/html/*.html')
.pipe(minifyHTML(opts))
.pipe(gulp.dest('./'));
});
gulp.task('minify-html', function() {
var opts = {
conditionals: true,
spare:true
};
return gulp.src('./build/html/*.html')
.pipe(minifyHTML(opts))
.pipe(gulp.dest('./'));
});
gulp.task('watch', function() {
livereload.listen();
gulp.watch('./dev/css/*.scss', ['cleancss', 'sass']);
gulp.watch('./dev/js/**/*.js', ['cleanjs', 'lint', 'scripts-dev']);
gulp.watch('./dev/html/*.html', ['minify-html-dev']);
gulp.watch('./build/css/*.css').on('change', function(){
livereload.changed(baseUrl+'/*.html', 80);
});
gulp.watch(['./dev/js/**/*.js', './static/js/contents/*.js']).on('change', function(){
livereload.changed(baseUrl+'/*.html', 80);
});
gulp.watch(['./*.html', './static/templates/*.html']).on('change', function(){
livereload.changed(baseUrl+'/*.html', 80);
});
});
gulp.task('test', function() {
livereload.listen();
gulp.watch('./dev/css/*.scss', ['cleancss', 'sass']);
gulp.watch('./dev/js/**/*.js', ['cleanjs', 'scripts-dev']);
gulp.watch('./build/html/*.html', ['minify-html']);
});
gulp.task('default', function() {
livereload.listen();
gulp.watch('./dev/css/*.scss', ['cleancss', 'sass']);
gulp.watch('./dev/js/**/*.js', ['cleanjs', 'scripts']);
gulp.watch('./build/html/*.html', ['minify-html']);
gulp.watch('./dev/css/*.css').on('change', function(){
livereload.changed(baseUrl+'/*.html', 80);
});
});