This repository has been archived by the owner on May 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
gulpfile.js
70 lines (61 loc) · 1.71 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
64
65
66
67
68
69
70
'use strict';
var gulp = require('gulp'),
minifycss = require('gulp-clean-css'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
header = require('gulp-header'),
buffer = require('vinyl-buffer'),
pkg = require('./package.json'),
eslint = require('gulp-eslint'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
rename = require('gulp-rename');
var banner = [
'/**',
' * <%= pkg.name %> v<%= pkg.version %>',
' * Copyright <%= pkg.author %>',
' * @link <%= pkg.repository.url %>',
' * @license <%= pkg.license %>',
' */',
''
].join('\n');
// Functions
function lint(cb) {
gulp.src('./src/js/**/*.js')
.pipe(eslint())
.pipe(eslint.format());
cb();
}
function scripts(cb) {
browserify({
entries: './src/js/inscrybmde.js',
standalone: 'InscrybMDE'
})
.bundle()
.pipe(source('inscrybmde.min.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(header(banner, { pkg: pkg }))
.pipe(gulp.dest('./dist/'));
cb();
}
function styles(cb) {
var css_files = [
'./node_modules/codemirror/lib/codemirror.css',
'./src/css/*.css',
'./node_modules/codemirror-spell-checker/src/css/spell-checker.css'
];
gulp.src(css_files)
.pipe(concat('inscrybmde.css'))
.pipe(minifycss())
.pipe(rename('inscrybmde.min.css'))
.pipe(buffer())
.pipe(header(banner, { pkg: pkg }))
.pipe(gulp.dest('./dist/'));
cb();
}
// Tasks
gulp.task('lint', lint);
gulp.task('scripts', gulp.series(lint, scripts));
gulp.task('styles', styles);
gulp.task('default', gulp.series(lint, scripts, styles));