2017-12-05 11:56:56 +01:00
|
|
|
'use strict';
|
2016-06-07 21:27:53 -05:00
|
|
|
|
2018-05-13 01:00:07 +02:00
|
|
|
var gulp = require('gulp');
|
2018-05-13 16:49:19 +02:00
|
|
|
var cleanCSS = require('gulp-clean-css');
|
2019-06-17 14:54:29 +02:00
|
|
|
var terser = require('gulp-terser');
|
2018-05-13 01:00:07 +02:00
|
|
|
var concat = require('gulp-concat');
|
|
|
|
var header = require('gulp-header');
|
|
|
|
var buffer = require('vinyl-buffer');
|
|
|
|
var pkg = require('./package.json');
|
|
|
|
var eslint = require('gulp-eslint');
|
|
|
|
var browserify = require('browserify');
|
|
|
|
var source = require('vinyl-source-stream');
|
|
|
|
var rename = require('gulp-rename');
|
2015-09-12 02:01:50 -05:00
|
|
|
|
2017-12-05 11:56:56 +01:00
|
|
|
var banner = ['/**',
|
|
|
|
' * <%= pkg.name %> v<%= pkg.version %>',
|
|
|
|
' * Copyright <%= pkg.author %>',
|
2019-08-20 01:10:31 +02:00
|
|
|
' * @link https://github.com/ionaru/easy-markdown-editor',
|
2017-12-05 11:56:56 +01:00
|
|
|
' * @license <%= pkg.license %>',
|
|
|
|
' */',
|
|
|
|
''].join('\n');
|
2015-09-12 02:01:50 -05:00
|
|
|
|
2020-02-06 20:56:07 +01:00
|
|
|
|
|
|
|
var css_files = [
|
|
|
|
'./node_modules/codemirror/lib/codemirror.css',
|
|
|
|
'./src/css/*.css',
|
|
|
|
'./node_modules/codemirror-spell-checker/src/css/spell-checker.css',
|
|
|
|
];
|
|
|
|
|
2018-05-13 01:00:07 +02:00
|
|
|
function lint() {
|
|
|
|
return gulp.src('./src/js/**/*.js')
|
2017-12-05 11:51:36 +01:00
|
|
|
.pipe(eslint())
|
|
|
|
.pipe(eslint.format())
|
|
|
|
.pipe(eslint.failAfterError());
|
2018-05-13 01:00:07 +02:00
|
|
|
}
|
2015-09-12 02:01:50 -05:00
|
|
|
|
2018-05-13 01:00:07 +02:00
|
|
|
function scripts() {
|
2018-04-23 15:18:49 +02:00
|
|
|
return browserify({entries: './src/js/easymde.js', standalone: 'EasyMDE'}).bundle()
|
|
|
|
.pipe(source('easymde.min.js'))
|
2017-12-05 11:51:36 +01:00
|
|
|
.pipe(buffer())
|
2019-06-17 14:54:29 +02:00
|
|
|
.pipe(terser())
|
2017-12-05 11:51:36 +01:00
|
|
|
.pipe(header(banner, {pkg: pkg}))
|
2017-12-05 11:56:56 +01:00
|
|
|
.pipe(gulp.dest('./dist/'));
|
2018-05-13 01:00:07 +02:00
|
|
|
}
|
2015-07-21 15:12:32 +01:00
|
|
|
|
2018-05-13 01:00:07 +02:00
|
|
|
function styles() {
|
2017-12-05 11:51:36 +01:00
|
|
|
return gulp.src(css_files)
|
2018-04-23 15:18:49 +02:00
|
|
|
.pipe(concat('easymde.css'))
|
2018-05-13 16:49:19 +02:00
|
|
|
.pipe(cleanCSS())
|
2018-04-23 15:18:49 +02:00
|
|
|
.pipe(rename('easymde.min.css'))
|
2017-12-05 11:51:36 +01:00
|
|
|
.pipe(buffer())
|
|
|
|
.pipe(header(banner, {pkg: pkg}))
|
2017-12-05 11:56:56 +01:00
|
|
|
.pipe(gulp.dest('./dist/'));
|
2018-05-13 01:00:07 +02:00
|
|
|
}
|
2015-07-21 15:12:32 +01:00
|
|
|
|
2020-02-06 20:56:07 +01:00
|
|
|
// Watch for file changes
|
|
|
|
function watch() {
|
2020-03-05 18:34:24 +01:00
|
|
|
gulp.watch('./src/js/**/*.js', scripts)
|
2020-02-06 20:56:07 +01:00
|
|
|
gulp.watch(css_files, styles)
|
|
|
|
}
|
|
|
|
|
2018-05-13 01:00:07 +02:00
|
|
|
var build = gulp.parallel(gulp.series(lint, scripts), styles);
|
|
|
|
|
|
|
|
gulp.task('default', build);
|
2020-02-06 20:56:07 +01:00
|
|
|
gulp.task('watch', gulp.series(build, watch));
|
2020-01-13 22:26:35 +01:00
|
|
|
gulp.task('lint', lint);
|