forked from Ionaru/easy-markdown-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (53 loc) · 1.69 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict';
var gulp = require('gulp');
var cleanCSS = require('gulp-clean-css');
var terser = require('gulp-terser');
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');
var banner = ['/**',
' * <%= pkg.name %> v<%= pkg.version %>',
' * Copyright <%= pkg.author %>',
' * @link https://github.com/ionaru/easy-markdown-editor',
' * @license <%= pkg.license %>',
' */',
''].join('\n');
var css_files = [
'./node_modules/codemirror/lib/codemirror.css',
'./src/css/*.css',
'./node_modules/codemirror-spell-checker/src/css/spell-checker.css',
];
function lint() {
return gulp.src('./src/js/**/*.js');
}
function scripts() {
return browserify({entries: './src/js/easymde.js', standalone: 'EasyMDE'}).bundle()
.pipe(source('easymde.min.js'))
.pipe(buffer())
.pipe(terser())
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest('./dist/'));
}
function styles() {
return gulp.src(css_files)
.pipe(concat('easymde.css'))
.pipe(cleanCSS())
.pipe(rename('easymde.min.css'))
.pipe(buffer())
.pipe(header(banner, {pkg: pkg}))
.pipe(gulp.dest('./dist/'));
}
// Watch for file changes
function watch() {
gulp.watch('./src/js/**/*.js', scripts);
gulp.watch(css_files, styles);
}
var build = gulp.parallel(gulp.series(lint, scripts), styles);
gulp.task('default', build);
gulp.task('watch', gulp.series(build, watch));
gulp.task('lint', lint);