2015-12-30 13:22:15 +00:00
|
|
|
|
|
|
|
var gulp = require('gulp'),
|
|
|
|
plumber = require('gulp-plumber'),
|
|
|
|
jshint = require('gulp-jshint'),
|
|
|
|
stylish = require('jshint-stylish'),
|
|
|
|
concat = require('gulp-concat'),
|
|
|
|
flatten = require('gulp-flatten'),
|
|
|
|
browserSync = require('browser-sync').create(),
|
2016-01-01 21:48:41 +00:00
|
|
|
sass = require('gulp-sass'),
|
|
|
|
nano = require('gulp-cssnano'),
|
2015-12-30 13:22:15 +00:00
|
|
|
uglify = require('gulp-uglify');
|
|
|
|
|
|
|
|
var client = {
|
|
|
|
|
|
|
|
html: {
|
|
|
|
|
|
|
|
'partials': 'pokemon_v2/client/components/**/views/*.html'
|
|
|
|
},
|
|
|
|
|
|
|
|
scripts: [
|
|
|
|
'pokemon_v2/client/app.js',
|
|
|
|
'pokemon_v2/client/components/**/scripts/*-module.js',
|
|
|
|
'pokemon_v2/client/components/**/scripts/*-routes.js',
|
|
|
|
'pokemon_v2/client/components/**/scripts/*-filters.js',
|
|
|
|
'pokemon_v2/client/components/**/scripts/*-service.js',
|
|
|
|
'pokemon_v2/client/components/**/scripts/*-directive.js',
|
|
|
|
'pokemon_v2/client/components/**/scripts/*-controller.js'
|
|
|
|
],
|
2016-01-01 21:48:41 +00:00
|
|
|
|
|
|
|
styles : {
|
|
|
|
|
|
|
|
src: [
|
|
|
|
'pokemon_v2/client/components/core/styles/core.scss',
|
|
|
|
'pokemon_v2/client/components/core/styles/!(core).scss',
|
|
|
|
'pokemon_v2/client/components/!(core)/styles/*.scss'
|
|
|
|
],
|
|
|
|
|
|
|
|
includes: [
|
|
|
|
'pokemon_v2/client/components/core/styles'
|
|
|
|
]
|
|
|
|
}
|
2015-12-30 13:22:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var out = {
|
|
|
|
|
2016-01-01 21:48:41 +00:00
|
|
|
all: 'assets/pokemon_v2/**/*.*',
|
|
|
|
scripts: 'assets/pokemon_v2/js',
|
|
|
|
styles: 'assets/pokemon_v2/css',
|
|
|
|
partials: 'assets/pokemon_v2/partials'
|
2015-12-30 13:22:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('html', function () {
|
|
|
|
|
|
|
|
return gulp.src(client.html.partials)
|
|
|
|
.pipe(flatten())
|
|
|
|
.pipe(gulp.dest(out.partials));
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('scripts', function () {
|
|
|
|
|
|
|
|
return gulp.src(client.scripts)
|
|
|
|
.pipe(plumber())
|
|
|
|
.pipe(jshint())
|
|
|
|
.pipe(jshint.reporter(stylish))
|
|
|
|
.pipe(uglify())
|
|
|
|
.pipe(concat('app.min.js'))
|
|
|
|
.pipe(gulp.dest(out.scripts));
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-01-01 21:48:41 +00:00
|
|
|
gulp.task('styles', function () {
|
|
|
|
|
|
|
|
return gulp.src(client.styles.src)
|
|
|
|
.pipe(plumber())
|
|
|
|
.pipe(sass({
|
|
|
|
outputStyle: 'expanded',
|
|
|
|
includePaths: client.styles.includes
|
|
|
|
}))
|
|
|
|
.pipe(nano())
|
|
|
|
.pipe(concat('app.min.css'))
|
|
|
|
.pipe(gulp.dest(out.styles))
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-12-30 13:22:15 +00:00
|
|
|
gulp.task('watch', function () {
|
|
|
|
|
2016-01-01 21:48:41 +00:00
|
|
|
gulp.watch(client.styles.src, ['styles']);
|
2015-12-30 13:22:15 +00:00
|
|
|
gulp.watch(client.html.partials, ['html']);
|
|
|
|
gulp.watch(client.scripts, ['scripts']);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('sync', function () {
|
|
|
|
|
|
|
|
browserSync.init({
|
|
|
|
|
|
|
|
port : 3000,
|
2016-01-01 21:48:41 +00:00
|
|
|
files : out.all,
|
2015-12-30 13:22:15 +00:00
|
|
|
logLevel : 'info', // info, debug, warn ,silent
|
|
|
|
// middleware : [fallback],
|
|
|
|
proxy : 'localhost:8000'
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-01-01 21:48:41 +00:00
|
|
|
gulp.task('default', ['html', 'scripts', 'styles']);
|
2015-12-30 13:22:15 +00:00
|
|
|
gulp.task('start', ['default', 'watch', 'sync']);
|