-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
executable file
·78 lines (61 loc) · 2.02 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
71
72
73
74
75
76
77
78
const _package = require('./package.json');
// GULP plugins
const gulp = require("gulp");
const concat = require("gulp-concat-util");
const uglify = require('gulp-uglify');
const rename = require("gulp-rename");
const wrapper = require('gulp-wrapper');
const filter = require('gulp-filter');
const replace = require('gulp-replace');
const less = require('gulp-less');
const minifyCSS = require('gulp-minify-css');
const prettyError = require('gulp-prettyerror');
const include = require("gulp-include");
const path = require('path');
// license header prepended to builds
const licenseHeader = '/*! EnlighterJS TinyMCE Plugin [[VERSION]] | Mozilla Public License 2.0 | https://tinymce.enlighterjs.org */\n';
// default release build
gulp.task('browser-js', function(){
return gulp.src('src/Plugin.js')
.pipe(prettyError())
// concat all files
.pipe(include())
// rename file
.pipe(rename('enlighterjs.tinymce.js'))
// add function wrapper and license header
.pipe(wrapper({
header: licenseHeader
}))
// add version string
.pipe(replace(/\[\[VERSION]]/g, _package.version))
// write merged version
.pipe(gulp.dest('dist'))
// create minified (compressed) version
.pipe(uglify({
compress: true,
output: {
comments: /^!/
}
}))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dist'))
});
// LESS to CSS (Base + Themes)
gulp.task('less', function () {
return gulp.src('src/editor-styles.less')
.pipe(prettyError())
.pipe(less())
.pipe(minifyCSS())
.pipe(concat('enlighterjs.tinymce.min.css'))
// add license header
.pipe(wrapper({
header: licenseHeader
}))
// add version string
.pipe(replace(/\[\[VERSION]]/g, _package.version))
.pipe(gulp.dest('dist'));
});
// default
gulp.task('default', gulp.series(['browser-js', 'less']));