mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge branch 'patch-5' of https://github.com/dcinzona/Orchard into 1.9.x
This commit is contained in:
@@ -4,20 +4,16 @@ var glob = require("glob"),
|
||||
gulpif = require("gulp-if"),
|
||||
gulp = require("gulp"),
|
||||
newer = require("gulp-newer"),
|
||||
plumber = require("gulp-plumber"),
|
||||
plumber = require("gulp-plumber"),
|
||||
sourcemaps = require("gulp-sourcemaps"),
|
||||
less = require("gulp-less"),
|
||||
autoprefixer = require("gulp-autoprefixer"),
|
||||
minify = require("gulp-minify-css"),
|
||||
autoprefixer = require("gulp-autoprefixer"),
|
||||
minify = require("gulp-minify-css"),
|
||||
typescript = require("gulp-typescript"),
|
||||
uglify = require("gulp-uglify"),
|
||||
rename = require("gulp-rename"),
|
||||
uglify = require("gulp-uglify"),
|
||||
rename = require("gulp-rename"),
|
||||
concat = require("gulp-concat"),
|
||||
header = require("gulp-header")
|
||||
|
||||
/*
|
||||
** GULP TASKS
|
||||
*/
|
||||
header = require("gulp-header")
|
||||
|
||||
// Incremental build (each asset group is built only if one or more inputs are newer than the output).
|
||||
gulp.task("build", function () {
|
||||
@@ -40,9 +36,14 @@ gulp.task("rebuild", function () {
|
||||
// Continuous watch (each asset group is built whenever one of its inputs changes).
|
||||
gulp.task("watch", function () {
|
||||
getAssetGroups().forEach(function (assetGroup) {
|
||||
gulp.watch(assetGroup.inputPaths, function (event) {
|
||||
assetGroup.watchPaths = !!assetGroup.watch ?
|
||||
assetGroup.watch.map(function (watchPath) {
|
||||
return path.join(assetGroup.basePath, watchPath);
|
||||
}).concat(assetGroup.inputPaths) : assetGroup.inputPaths;
|
||||
gulp.watch(assetGroup.watchPaths, function (event) {
|
||||
console.log("Asset file '" + event.path + "' was " + event.type + ", rebuilding output '" + assetGroup.outputPath + "'.");
|
||||
var task = createAssetGroupTask(assetGroup);
|
||||
var doRebuild = true;
|
||||
var task = createAssetGroupTask(assetGroup, doRebuild);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -95,6 +96,7 @@ function buildCssPipeline(assetGroup, doRebuild) {
|
||||
throw "Input file '" + inputPath + "' is not of a valid type for output file '" + assetGroup.outputPath + "'.";
|
||||
});
|
||||
var doConcat = path.basename(assetGroup.outputFileName, ".css") !== "@";
|
||||
var generateSourceMaps = assetGroup.hasOwnProperty("generateSourceMaps") ? assetGroup.generateSourceMaps : true;
|
||||
return gulp.src(assetGroup.inputPaths)
|
||||
.pipe(gulpif(!doRebuild,
|
||||
gulpif(doConcat,
|
||||
@@ -104,7 +106,7 @@ function buildCssPipeline(assetGroup, doRebuild) {
|
||||
ext: ".css"
|
||||
}))))
|
||||
.pipe(plumber())
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(gulpif(generateSourceMaps, sourcemaps.init()))
|
||||
.pipe(gulpif("*.less", less()))
|
||||
.pipe(gulpif(doConcat, concat(assetGroup.outputFileName)))
|
||||
.pipe(autoprefixer({ browsers: ["last 2 versions"] }))
|
||||
@@ -115,7 +117,7 @@ function buildCssPipeline(assetGroup, doRebuild) {
|
||||
// "** Any changes made directly to this file will be overwritten next time the Gulp compilation runs.\n" +
|
||||
// "** For more information, see the Readme.txt file in the Gulp solution folder.\n" +
|
||||
// "*/\n\n"))
|
||||
.pipe(sourcemaps.write())
|
||||
.pipe(gulpif(generateSourceMaps, sourcemaps.write()))
|
||||
.pipe(gulp.dest(assetGroup.outputDir))
|
||||
.pipe(minify())
|
||||
.pipe(rename({
|
||||
@@ -131,6 +133,7 @@ function buildJsPipeline(assetGroup, doRebuild) {
|
||||
throw "Input file '" + inputPath + "' is not of a valid type for output file '" + assetGroup.outputPath + "'.";
|
||||
});
|
||||
var doConcat = path.basename(assetGroup.outputFileName, ".js") !== "@";
|
||||
var generateSourceMaps = assetGroup.hasOwnProperty("generateSourceMaps") ? assetGroup.generateSourceMaps : true;
|
||||
return gulp.src(assetGroup.inputPaths)
|
||||
.pipe(gulpif(!doRebuild,
|
||||
gulpif(doConcat,
|
||||
@@ -140,14 +143,14 @@ function buildJsPipeline(assetGroup, doRebuild) {
|
||||
ext: ".js"
|
||||
}))))
|
||||
.pipe(plumber())
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(gulpif(generateSourceMaps, sourcemaps.init()))
|
||||
.pipe(gulpif("*.ts", typescript({
|
||||
declaration: false,
|
||||
//noImplicitAny: true,
|
||||
noEmitOnError: true,
|
||||
sortOutput: true,
|
||||
}).js))
|
||||
.pipe(gulpif(doConcat, concat(assetGroup.outputFileName)))
|
||||
.pipe(gulpif(doConcat, concat(assetGroup.outputFileName)))
|
||||
// TODO: Start using below whenever gulp-header supports sourcemaps.
|
||||
//.pipe(header(
|
||||
// "/*\n" +
|
||||
@@ -155,11 +158,11 @@ function buildJsPipeline(assetGroup, doRebuild) {
|
||||
// "** Any changes made directly to this file will be overwritten next time the Gulp compilation runs.\n" +
|
||||
// "** For more information, see the Readme.txt file in the Gulp solution folder.\n" +
|
||||
// "*/\n\n"))
|
||||
.pipe(sourcemaps.write())
|
||||
.pipe(gulpif(generateSourceMaps, sourcemaps.write()))
|
||||
.pipe(gulp.dest(assetGroup.outputDir))
|
||||
.pipe(uglify())
|
||||
.pipe(rename({
|
||||
suffix: ".min"
|
||||
}))
|
||||
.pipe(gulp.dest(assetGroup.outputDir));
|
||||
}
|
||||
.pipe(uglify())
|
||||
.pipe(rename({
|
||||
suffix: ".min"
|
||||
}))
|
||||
.pipe(gulp.dest(assetGroup.outputDir));
|
||||
}
|
||||
|
Reference in New Issue
Block a user