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

84 lines
2.4 KiB
JavaScript
Raw Normal View History

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