2016-05-05 19:44:17 +00:00
|
|
|
var gulp = require('gulp'),
|
|
|
|
sass = require('gulp-sass'),
|
|
|
|
browserSync = require('browser-sync'),
|
|
|
|
concat = require('gulp-concat'),
|
|
|
|
autoprefixer = require('gulp-autoprefixer'),
|
|
|
|
rename = require('gulp-rename'),
|
|
|
|
imagemin = require('gulp-imagemin'),
|
|
|
|
plumber = require('gulp-plumber'),
|
|
|
|
del = require('del'),
|
|
|
|
cleanCSS = require('gulp-clean-css'),
|
|
|
|
useref = require('gulp-useref'),
|
2016-12-14 20:53:12 +00:00
|
|
|
staticHash = require('gulp-static-hash'),
|
|
|
|
|
2016-12-13 14:08:40 +00:00
|
|
|
browserify = require('browserify'),
|
|
|
|
source = require('vinyl-source-stream'),
|
|
|
|
buffer = require('vinyl-buffer'),
|
2016-12-14 20:53:12 +00:00
|
|
|
streamify = require('gulp-streamify'),
|
|
|
|
|
2016-12-13 14:08:40 +00:00
|
|
|
gutil = require('gulp-util'),
|
|
|
|
uglify = require('gulp-uglify'),
|
|
|
|
sourcemaps = require('gulp-sourcemaps'),
|
|
|
|
babel = require('gulp-babel');
|
2016-05-05 19:44:17 +00:00
|
|
|
|
|
|
|
gulp.task('browser-sync', function() {
|
|
|
|
browserSync({
|
2016-12-14 20:53:12 +00:00
|
|
|
server: { baseDir: 'src' },
|
2016-05-05 19:44:17 +00:00
|
|
|
notify: false
|
2016-12-14 20:53:12 +00:00
|
|
|
})
|
2016-12-13 14:08:40 +00:00
|
|
|
})
|
2016-05-05 19:44:17 +00:00
|
|
|
|
2016-12-14 20:53:12 +00:00
|
|
|
gulp.task('css', function () {
|
|
|
|
gulp.src('src/scss/main.scss')
|
|
|
|
.pipe(plumber())
|
|
|
|
.pipe(sass())
|
|
|
|
.pipe(autoprefixer({ browsers: ['last 3 versions'], cascade: false }))
|
|
|
|
.pipe(gulp.dest('src/css'))
|
|
|
|
.pipe(browserSync.reload({stream: true}))
|
2016-12-13 14:08:40 +00:00
|
|
|
})
|
|
|
|
|
2016-12-14 20:53:12 +00:00
|
|
|
gulp.task('browserify', function() {
|
|
|
|
return browserify('src/js/main.js')
|
|
|
|
.bundle()
|
|
|
|
.pipe(source('app.js'))
|
|
|
|
.pipe(streamify(babel({ presets: ['es2015'] })))
|
|
|
|
.pipe(gulp.dest('src/js'))
|
|
|
|
.pipe(browserSync.reload({stream: true}))
|
|
|
|
})
|
2016-05-05 19:44:17 +00:00
|
|
|
|
|
|
|
gulp.task('clean', function() {
|
2016-12-14 20:53:12 +00:00
|
|
|
del.sync('build')
|
|
|
|
})
|
2016-05-05 19:44:17 +00:00
|
|
|
|
|
|
|
gulp.task('images', function() {
|
2016-12-14 20:53:12 +00:00
|
|
|
gulp.src('src/img/**/*')
|
|
|
|
.pipe(plumber())
|
|
|
|
.pipe(gulp.dest('build/img'))
|
|
|
|
})
|
2016-05-05 19:44:17 +00:00
|
|
|
|
2016-12-15 14:29:43 +00:00
|
|
|
gulp.task('imagemin', function() {
|
|
|
|
gulp.src('src/img/**/*')
|
|
|
|
.pipe(plumber())
|
|
|
|
.pipe(imagemin())
|
|
|
|
.pipe(gulp.dest('src/img'))
|
|
|
|
})
|
|
|
|
|
2016-07-02 09:28:09 +00:00
|
|
|
gulp.task('demo', function() {
|
|
|
|
gulp.src(['src/demo/**/*'])
|
2016-12-14 20:53:12 +00:00
|
|
|
.pipe(gulp.dest('build/demo'))
|
|
|
|
})
|
2016-07-02 09:28:09 +00:00
|
|
|
|
2016-11-09 10:30:26 +00:00
|
|
|
gulp.task('dapps', function() {
|
|
|
|
gulp.src(['src/dapps/**/*'])
|
2016-12-14 20:53:12 +00:00
|
|
|
.pipe(gulp.dest('build/dapps'))
|
|
|
|
})
|
|
|
|
|
2017-03-15 16:17:24 +00:00
|
|
|
|
2016-12-14 20:53:12 +00:00
|
|
|
gulp.task('watch', ['css', 'browserify', 'browser-sync'], function() {
|
|
|
|
gulp.watch('src/scss/**/*.+(sass|scss)', ['css'])
|
|
|
|
gulp.watch('src/*.html', browserSync.reload)
|
|
|
|
gulp.watch('src/js/main.js', ['browserify'])
|
2016-12-15 12:01:41 +00:00
|
|
|
gulp.watch('src/js/mc-validate.js', ['browserify'])
|
2016-12-14 20:53:12 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
gulp.task('build', ['clean', 'css', 'browserify', 'images', 'demo', 'dapps'], function() {
|
|
|
|
|
|
|
|
gulp.src(['src/css/main.css'])
|
|
|
|
.pipe(cleanCSS({compatibility: 'ie9'}))
|
|
|
|
.pipe(gulp.dest('build/css'))
|
|
|
|
|
2016-12-15 12:01:41 +00:00
|
|
|
gulp.src(['src/js/mc-validate.js','src/js/app.js'])
|
2016-12-13 14:08:40 +00:00
|
|
|
.pipe(uglify())
|
2016-12-15 12:01:41 +00:00
|
|
|
//.on('error', gutil.log)
|
2016-12-14 20:53:12 +00:00
|
|
|
.pipe(gulp.dest('build/js'))
|
2016-05-05 19:44:17 +00:00
|
|
|
|
|
|
|
gulp.src('src/*.html')
|
2016-12-14 20:53:12 +00:00
|
|
|
.pipe(useref({ noAssets:true }))
|
|
|
|
.pipe(staticHash({asset: 'static'}))
|
|
|
|
.pipe(gulp.dest('build'))
|
2016-05-05 19:44:17 +00:00
|
|
|
|
2016-12-13 14:08:40 +00:00
|
|
|
gulp.src('src/fonts/**/*')
|
2016-12-14 20:53:12 +00:00
|
|
|
.pipe(gulp.dest('build/fonts'))
|
2016-06-09 12:03:55 +00:00
|
|
|
|
2016-12-13 14:08:40 +00:00
|
|
|
gulp.src('src/*.php')
|
2016-12-14 20:53:12 +00:00
|
|
|
.pipe(useref({ noAssets:true }))
|
|
|
|
.pipe(gulp.dest('build'))
|
2017-05-29 16:06:05 +00:00
|
|
|
|
|
|
|
gulp.src('src/*.pdf')
|
2017-05-29 16:14:24 +00:00
|
|
|
// .pipe(useref({ noAssets:true }))
|
2017-05-29 16:06:05 +00:00
|
|
|
.pipe(gulp.dest('build'))
|
2017-05-29 16:09:20 +00:00
|
|
|
|
2016-12-14 20:53:12 +00:00
|
|
|
})
|
2016-05-05 19:44:17 +00:00
|
|
|
|
2016-12-14 20:53:12 +00:00
|
|
|
gulp.task('default', ['watch'])
|