Skip to content

Commit

Permalink
up gulp
Browse files Browse the repository at this point in the history
  • Loading branch information
bondrogeen committed Feb 12, 2019
1 parent 1ff5ffa commit a85e29a
Show file tree
Hide file tree
Showing 3 changed files with 1,713 additions and 363 deletions.
74 changes: 24 additions & 50 deletions gulpfile.js
@@ -1,7 +1,6 @@
'use strict';

var gulp = require('gulp'),
watch = require('gulp-watch'),
gutil = require('gulp-util'),
gzip = require('gulp-gzip'),
cssmin = require('gulp-cssmin'),
Expand All @@ -12,9 +11,6 @@ var gulp = require('gulp'),
luaminify = require('gulp-luaminify'),
rigger = require('gulp-rigger');




var path = {
build: 'files/',
src: {
Expand All @@ -23,6 +19,7 @@ var path = {
style: 'src/assets/css/*.css',
img: 'src/assets/images/**/*.*',
lua: 'src/lua/**/*.*',
info: 'src/assets/info/**/*.*',
fonts: 'src/assets/fonts/**/*.*'
},
watch: {
Expand All @@ -31,6 +28,7 @@ var path = {
style: 'src/assets/css/*.css',
img: 'src/assets/images/**/*.*',
lua: 'src/lua/**/*.*',
info: 'src/assets/info/**/*.*',
fonts: 'src/assets/fonts/**/*.*'
},
clean: './build'
Expand All @@ -43,71 +41,47 @@ var optionsDef = {
minifyJS:true
};

gulp.task('html:build', function () {
gulp.src(path.src.html)
function html () {
return gulp.src(path.src.html)
.pipe(rigger())
.pipe(htmlmin(optionsDef))
.pipe(replace('<?lua', '\n<?lua'))
// .pipe(replace(/^.*/, function(val) {
// console.log("\n______________________________________\n");
// console.log(val);
//
// return val;
// }))
.pipe(gulp.dest(path.build));
});
};

gulp.task('js:build', function () {
gulp.src(path.src.js)
function js() {
return gulp.src(path.src.js)
.pipe(rigger())
.pipe(uglify())
.pipe(gzip())
.pipe(gulp.dest(path.build));
});
};

gulp.task('css:build', function () {
gulp.src(path.src.style)
// .pipe(rigger())
function style() {
return gulp.src(path.src.style)
.pipe(cssmin())
.pipe(rename({basename: "style"}))
.pipe(gzip())
.pipe(gulp.dest(path.build));
});
};

gulp.task('img:build', function () {
gulp.src(path.src.img)
function img() {
return gulp.src(path.src.img)
.pipe(gulp.dest(path.build));
});
};

gulp.task('lua:build', function () {
function lua() {
return gulp.src(path.src.lua)
.pipe(luaminify())
.pipe(gulp.dest(path.build));
});

gulp.task('build', [
'html:build',
'lua:build',
'js:build',
'css:build',
'img:build'
]);

gulp.task('watch', function () {
watch([path.watch.html], function (event, cb) {
gulp.start('html:build');
})

watch([path.watch.js], function (event, cb) {
gulp.start('js:build');
});

watch([path.watch.lua], function (event, cb) {
gulp.start('lua:build');
});
};

watch([path.watch.style], function (event, cb) {
gulp.start('css:build');
});
function watch() {
gulp.watch(path.watch.html, html);
gulp.watch(path.watch.js, js);
gulp.watch(path.watch.lua, lua);
gulp.watch(path.watch.style, style);
}

});
gulp.task('build', gulp.parallel(html, js, style, img, lua));
gulp.task('watch', gulp.series(watch));

0 comments on commit a85e29a

Please sign in to comment.