2
0
mirror of https://github.com/Ionaru/easy-markdown-editor synced 2025-06-27 13:11:01 -06:00
easy-markdown-editor/gulpfile.js

84 lines
2.4 KiB
JavaScript
Raw Normal View History

2017-12-05 11:56:56 +01:00
'use strict';
2017-12-05 11:56:56 +01:00
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'),
debug = require('gulp-debug'),
eslint = require('gulp-eslint'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
rename = require('gulp-rename');
2017-12-05 11:56:56 +01:00
var banner = ['/**',
' * <%= pkg.name %> v<%= pkg.version %>',
' * Copyright <%= pkg.author %>',
' * @link <%= pkg.repository.url %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n');
2017-12-05 11:56:56 +01:00
gulp.task('lint', function () {
gulp.src('./src/js/**/*.js')
2017-12-05 11:51:36 +01:00
.pipe(debug())
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
function taskBrowserify(opts) {
2017-12-05 11:56:56 +01:00
return browserify('./src/js/simplemde.js', opts)
2017-12-05 11:51:36 +01:00
.bundle();
}
2017-12-05 11:56:56 +01:00
gulp.task('browserify:debug', ['lint'], function () {
return taskBrowserify({debug: true, standalone: 'SimpleMDE'})
.pipe(source('simplemde.debug.js'))
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('./debug/'));
});
2017-12-05 11:56:56 +01:00
gulp.task('browserify', ['lint'], function () {
return taskBrowserify({standalone: 'SimpleMDE'})
.pipe(source('simplemde.js'))
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('./debug/'));
});
2015-07-21 15:12:32 +01:00
2017-12-05 11:56:56 +01:00
gulp.task('scripts', ['browserify:debug', 'browserify', 'lint'], function () {
var js_files = ['./debug/simplemde.js'];
2017-12-05 11:51:36 +01:00
return gulp.src(js_files)
2017-12-05 11:56:56 +01:00
.pipe(concat('simplemde.min.js'))
2017-12-05 11:51:36 +01:00
.pipe(uglify())
.pipe(buffer())
.pipe(header(banner, {pkg: pkg}))
2017-12-05 11:56:56 +01:00
.pipe(gulp.dest('./dist/'));
2015-07-21 15:12:32 +01:00
});
2017-12-05 11:56:56 +01:00
gulp.task('styles', function () {
2017-12-05 11:51:36 +01:00
var css_files = [
2017-12-05 11:56:56 +01:00
'./node_modules/codemirror/lib/codemirror.css',
'./src/css/*.css',
'./node_modules/codemirror-spell-checker/src/css/spell-checker.css'
2017-12-05 11:51:36 +01:00
];
return gulp.src(css_files)
2017-12-05 11:56:56 +01:00
.pipe(concat('simplemde.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('./debug/'))
2017-12-05 11:51:36 +01:00
.pipe(minifycss())
2017-12-05 11:56:56 +01:00
.pipe(rename('simplemde.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/'));
2015-07-21 15:12:32 +01:00
});
2017-12-05 11:56:56 +01:00
gulp.task('default', ['scripts', 'styles']);