0
0
Fork 0
mirror of https://gitlab.com/Oreolek/salet-module.git synced 2024-07-01 06:15:04 +03:00

Gulpfile update

This commit is contained in:
Alexander Yakovlev 2016-02-01 19:44:22 +07:00
parent 53d9009fc6
commit 3215b865f5
3 changed files with 35 additions and 38 deletions

View file

@ -10,25 +10,23 @@ sass = require('gulp-sass')
uglify = require('gulp-uglify') uglify = require('gulp-uglify')
buffer = require('vinyl-buffer') buffer = require('vinyl-buffer')
zip = require('gulp-zip') zip = require('gulp-zip')
_ = require('lodash')
concat = require('gulp-concat') concat = require('gulp-concat')
reload = browserSync.reload reload = browserSync.reload
html = (target) -> html = (target) ->
return () -> return () ->
return gulp.src(['html/index.html','html/en.html']) return gulp.src(['html/index.html']).pipe(gulp.dest(target))
.pipe(gulp.dest(target));
# Images
img = (target) -> img = (target) ->
return () -> return () ->
return gulp.src(['img/*.png', 'img/*.jpeg', 'img/*.jpg']) return gulp.src(['img/*.png', 'img/*.jpeg', 'img/*.jpg']).pipe(gulp.dest(target))
.pipe(gulp.dest(target));
# Audio assets
audio = (target) -> audio = (target) ->
return () -> return () ->
return gulp.src(['audio/*.mp3']) return gulp.src(['audio/*.mp3']).pipe(gulp.dest(target))
.pipe(gulp.dest(target));
gulp.task('html', html('./build')) gulp.task('html', html('./build'))
gulp.task('img', img('./build/img')) gulp.task('img', img('./build/img'))
@ -37,21 +35,14 @@ gulp.task('audio', audio('./build/audio'))
gulp.task('sass', () -> gulp.task('sass', () ->
gulp.src('sass/main.scss') gulp.src('sass/main.scss')
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError)) .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(gulp.dest('./build/css')); .pipe(gulp.dest('./build/css'))
) )
sources = [ bundler = watchify(browserify({
'./game/begin.coffee',
'./game/story.coffee',
'./game/init.coffee',
]
opts = _.assign({}, watchify.args, {
entries: ["./build/game/main.coffee"] entries: ["./build/game/main.coffee"]
debug: true debug: true
transform: [coffeify] transform: [coffeify]
}); }))
bundler = watchify(browserify(opts))
bundle = () -> bundle = () ->
return bundler.bundle() return bundler.bundle()
@ -60,15 +51,16 @@ bundle = () ->
.pipe(gulp.dest('./build/game')) .pipe(gulp.dest('./build/game'))
gulp.task('concatCoffee', () -> gulp.task('concatCoffee', () ->
return gulp.src(sources) return gulp.src([
.pipe(concat('./main.coffee')) './game/begin.coffee',
.pipe(gulp.dest('./build/game')) './game/story.coffee',
]).pipe(concat('./main.coffee')).pipe(gulp.dest('./build/game'))
) )
gulp.task('coffee', ['concatCoffee'], bundle) gulp.task('coffee', ['concatCoffee'], bundle)
bundler.on('update', bundle); bundler.on('update', bundle)
bundler.on('log', gutil.log); bundler.on('log', gutil.log)
gulp.task('build', ['html', 'img', 'sass', 'coffee', 'audio']) gulp.task('build', ['html', 'img', 'sass', 'coffee', 'audio'])
@ -85,7 +77,6 @@ gulp.task('serve', ['build'], () ->
gulp.watch(['./html/*.html'], ['html']) gulp.watch(['./html/*.html'], ['html'])
gulp.watch(['./sass/*.scss'], ['sass']) gulp.watch(['./sass/*.scss'], ['sass'])
gulp.watch(['./img/*.png', './img/*.jpeg', './img/*.jpg'], ['img']) gulp.watch(['./img/*.png', './img/*.jpeg', './img/*.jpg'], ['img'])
gulp.watch(['./lib/*.coffee', './lib/*.js', './game/*.coffee'], ['coffee'])
gulp.watch(['./build/css/main.css'], sassListener) gulp.watch(['./build/css/main.css'], sassListener)
gulp.watch( gulp.watch(
@ -93,25 +84,25 @@ gulp.task('serve', ['build'], () ->
browserSync.reload) browserSync.reload)
) )
gulp.task('html-dist', html('./dist')); gulp.task('html-dist', html('./dist'))
gulp.task('img-dist', img('./dist/img')); gulp.task('img-dist', img('./dist/img'))
gulp.task('audio-dist', audio('./dist/audio')); gulp.task('audio-dist', audio('./dist/audio'))
gulp.task('legal-dist', () -> gulp.task('legal-dist', () ->
return gulp.src(['LICENSE.txt']) return gulp.src(['LICENSE.txt'])
.pipe(gulp.dest("./dist")); .pipe(gulp.dest("./dist"))
); )
gulp.task('sass-dist', () -> gulp.task('sass-dist', () ->
return gulp.src('./sass/main.scss') return gulp.src('./sass/main.scss')
.pipe(sass({outputStyle: 'compressed'})) .pipe(sass({outputStyle: 'compressed'}))
.pipe(gulp.dest('./dist/css')); .pipe(gulp.dest('./dist/css'))
); )
distBundler = browserify({ distBundler = browserify({
debug: false, debug: false,
entries: ['./build/game/main.coffee'], entries: ['./build/game/main.coffee'],
transform: ['coffeeify'] transform: ['coffeeify']
}); })
gulp.task('coffee-dist', ['concatCoffee'], () -> gulp.task('coffee-dist', ['concatCoffee'], () ->
return distBundler.bundle() return distBundler.bundle()
@ -119,13 +110,20 @@ gulp.task('coffee-dist', ['concatCoffee'], () ->
.pipe(buffer()) .pipe(buffer())
.pipe(uglify()) .pipe(uglify())
.on('error', gutil.log) .on('error', gutil.log)
.pipe(gulp.dest('./dist/game')); .pipe(gulp.dest('./dist/game'))
); )
gulp.task('dist', ['html-dist', 'img-dist', 'sass-dist', 'coffee-dist', 'audio-dist', 'legal-dist']); gulp.task('dist', [
'html-dist',
'img-dist',
'sass-dist',
'coffee-dist',
'audio-dist',
'legal-dist'
])
gulp.task('zip', ['dist'], () -> gulp.task('zip', ['dist'], () ->
return gulp.src('dist/**') return gulp.src('dist/**')
.pipe(zip('dist.zip')) .pipe(zip('dist.zip'))
.pipe(gulp.dest('.')); .pipe(gulp.dest('.'))
); )

View file

@ -15,7 +15,6 @@
"gulp-zip": "^3.0.2", "gulp-zip": "^3.0.2",
"gulp-concat": "^2.6.0", "gulp-concat": "^2.6.0",
"gulp-sass": "^2.1.1", "gulp-sass": "^2.1.1",
"lodash": "^3.6.0",
"vinyl-buffer": "^1.0.0", "vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0", "vinyl-source-stream": "^1.1.0",
"watchify": "^3.1.0" "watchify": "^3.1.0"

@ -1 +1 @@
Subproject commit 643bd8eaeb7a2a692fec3add22a3b61eff0fb62c Subproject commit 6384789f952c297356a94aded5900d199d09ae87