diff --git a/.babelrc b/.babelrc new file mode 100644 index 000000000..244d28bfd --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": [ "es2015" ] +} diff --git a/gulpfile.babel.js b/gulpfile.babel.js new file mode 100644 index 000000000..fe48c93d2 --- /dev/null +++ b/gulpfile.babel.js @@ -0,0 +1,52 @@ +import gulp from "gulp" +import stylus from "gulp-stylus" +import babel from "gulp-babel" +import cssmin from "gulp-cssmin" +import uglify from "gulp-uglify" +import rename from "gulp-rename" + +const paths = { + style: "src/style/flatpickr.styl", + script: "src/flatpickr.js", + themes: "./src/style/themes/*.styl" +}; + +export function script() { + return gulp.src(paths.script) + .pipe(babel({presets: ['es2015']})) + .pipe(uglify()).on('error', errorHandler) + .pipe(rename({ suffix: '.min'})) + .pipe(gulp.dest('dist')); +}; + +export function style() { + return gulp.src(paths.style) + .pipe(stylus()) + .pipe(cssmin()).on('error', errorHandler) + .pipe(rename({ suffix: '.min'})) + .pipe(gulp.dest('dist')); +}; + +export function themes() { + return gulp.src(paths.themes) + .pipe(stylus()) + .pipe(cssmin()).on('error', errorHandler) + .pipe(rename({ prefix: 'flatpickr.',suffix: '.min'})) + .pipe(gulp.dest('dist')); +}; + +export function watch() { + gulp.watch('./src/style/*.styl', style); + gulp.watch('./src/style/themes/*.styl', themes); + gulp.watch(paths.script, script); +}; + + +// Handle the error +function errorHandler (error) { + console.log(error.toString()); +} + +const build = gulp.parallel(script, style, themes,watch); +export {build} +export default build; diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index 2300e88bb..000000000 --- a/gulpfile.js +++ /dev/null @@ -1,48 +0,0 @@ -var gulp = require('gulp'), -stylus = require('gulp-stylus'), -babel = require('gulp-babel'), -cssmin = require('gulp-cssmin'), -uglify = require('gulp-uglify'), -rename = require("gulp-rename"); - -gulp.task('style', function () { - return gulp.src('./src/style/flatpickr.styl') - .pipe(stylus()) - .pipe(cssmin()).on('error', errorHandler) - .pipe(rename({ suffix: '.min'})) - .pipe(gulp.dest('dist')); -}); - -gulp.task('themes', function () { - return gulp.src('./src/style/themes/*.styl') - .pipe(stylus()) - .pipe(cssmin()).on('error', errorHandler) - .pipe(rename({ prefix: 'flatpickr.',suffix: '.min'})) - .pipe(gulp.dest('dist')); -}); - -gulp.task('watch', function () { - //gulp.watch('./src/**/*.scss', ['sass']); - gulp.watch('./src/style/*.styl', ['style']); - gulp.watch('./src/style/themes/*.styl', ['themes']); - gulp.watch('src/flatpickr.js', ['compress-js']); -}); - - - -gulp.task('compress-js', function() { - return gulp.src('src/flatpickr.js') - .pipe(babel({presets: ['es2015']})) - .pipe(uglify()).on('error', errorHandler) - .pipe(rename({ suffix: '.min'})) - .pipe(gulp.dest('dist')); -}); - - - -// Handle the error -function errorHandler (error) { - console.log(error.toString()); -} - -gulp.task('default', ['compress-js', 'style', 'themes','watch' ]);