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"),
|
gulpif = require("gulp-if"),
|
||||||
gulp = require("gulp"),
|
gulp = require("gulp"),
|
||||||
newer = require("gulp-newer"),
|
newer = require("gulp-newer"),
|
||||||
plumber = require("gulp-plumber"),
|
plumber = require("gulp-plumber"),
|
||||||
sourcemaps = require("gulp-sourcemaps"),
|
sourcemaps = require("gulp-sourcemaps"),
|
||||||
less = require("gulp-less"),
|
less = require("gulp-less"),
|
||||||
autoprefixer = require("gulp-autoprefixer"),
|
autoprefixer = require("gulp-autoprefixer"),
|
||||||
minify = require("gulp-minify-css"),
|
minify = require("gulp-minify-css"),
|
||||||
typescript = require("gulp-typescript"),
|
typescript = require("gulp-typescript"),
|
||||||
uglify = require("gulp-uglify"),
|
uglify = require("gulp-uglify"),
|
||||||
rename = require("gulp-rename"),
|
rename = require("gulp-rename"),
|
||||||
concat = require("gulp-concat"),
|
concat = require("gulp-concat"),
|
||||||
header = require("gulp-header")
|
header = require("gulp-header")
|
||||||
|
|
||||||
/*
|
|
||||||
** GULP TASKS
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Incremental build (each asset group is built only if one or more inputs are newer than the output).
|
// Incremental build (each asset group is built only if one or more inputs are newer than the output).
|
||||||
gulp.task("build", function () {
|
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).
|
// Continuous watch (each asset group is built whenever one of its inputs changes).
|
||||||
gulp.task("watch", function () {
|
gulp.task("watch", function () {
|
||||||
getAssetGroups().forEach(function (assetGroup) {
|
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 + "'.");
|
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 + "'.";
|
throw "Input file '" + inputPath + "' is not of a valid type for output file '" + assetGroup.outputPath + "'.";
|
||||||
});
|
});
|
||||||
var doConcat = path.basename(assetGroup.outputFileName, ".css") !== "@";
|
var doConcat = path.basename(assetGroup.outputFileName, ".css") !== "@";
|
||||||
|
var generateSourceMaps = assetGroup.hasOwnProperty("generateSourceMaps") ? assetGroup.generateSourceMaps : true;
|
||||||
return gulp.src(assetGroup.inputPaths)
|
return gulp.src(assetGroup.inputPaths)
|
||||||
.pipe(gulpif(!doRebuild,
|
.pipe(gulpif(!doRebuild,
|
||||||
gulpif(doConcat,
|
gulpif(doConcat,
|
||||||
@@ -104,7 +106,7 @@ function buildCssPipeline(assetGroup, doRebuild) {
|
|||||||
ext: ".css"
|
ext: ".css"
|
||||||
}))))
|
}))))
|
||||||
.pipe(plumber())
|
.pipe(plumber())
|
||||||
.pipe(sourcemaps.init())
|
.pipe(gulpif(generateSourceMaps, sourcemaps.init()))
|
||||||
.pipe(gulpif("*.less", less()))
|
.pipe(gulpif("*.less", less()))
|
||||||
.pipe(gulpif(doConcat, concat(assetGroup.outputFileName)))
|
.pipe(gulpif(doConcat, concat(assetGroup.outputFileName)))
|
||||||
.pipe(autoprefixer({ browsers: ["last 2 versions"] }))
|
.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" +
|
// "** 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" +
|
// "** For more information, see the Readme.txt file in the Gulp solution folder.\n" +
|
||||||
// "*/\n\n"))
|
// "*/\n\n"))
|
||||||
.pipe(sourcemaps.write())
|
.pipe(gulpif(generateSourceMaps, sourcemaps.write()))
|
||||||
.pipe(gulp.dest(assetGroup.outputDir))
|
.pipe(gulp.dest(assetGroup.outputDir))
|
||||||
.pipe(minify())
|
.pipe(minify())
|
||||||
.pipe(rename({
|
.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 + "'.";
|
throw "Input file '" + inputPath + "' is not of a valid type for output file '" + assetGroup.outputPath + "'.";
|
||||||
});
|
});
|
||||||
var doConcat = path.basename(assetGroup.outputFileName, ".js") !== "@";
|
var doConcat = path.basename(assetGroup.outputFileName, ".js") !== "@";
|
||||||
|
var generateSourceMaps = assetGroup.hasOwnProperty("generateSourceMaps") ? assetGroup.generateSourceMaps : true;
|
||||||
return gulp.src(assetGroup.inputPaths)
|
return gulp.src(assetGroup.inputPaths)
|
||||||
.pipe(gulpif(!doRebuild,
|
.pipe(gulpif(!doRebuild,
|
||||||
gulpif(doConcat,
|
gulpif(doConcat,
|
||||||
@@ -140,14 +143,14 @@ function buildJsPipeline(assetGroup, doRebuild) {
|
|||||||
ext: ".js"
|
ext: ".js"
|
||||||
}))))
|
}))))
|
||||||
.pipe(plumber())
|
.pipe(plumber())
|
||||||
.pipe(sourcemaps.init())
|
.pipe(gulpif(generateSourceMaps, sourcemaps.init()))
|
||||||
.pipe(gulpif("*.ts", typescript({
|
.pipe(gulpif("*.ts", typescript({
|
||||||
declaration: false,
|
declaration: false,
|
||||||
//noImplicitAny: true,
|
//noImplicitAny: true,
|
||||||
noEmitOnError: true,
|
noEmitOnError: true,
|
||||||
sortOutput: true,
|
sortOutput: true,
|
||||||
}).js))
|
}).js))
|
||||||
.pipe(gulpif(doConcat, concat(assetGroup.outputFileName)))
|
.pipe(gulpif(doConcat, concat(assetGroup.outputFileName)))
|
||||||
// TODO: Start using below whenever gulp-header supports sourcemaps.
|
// TODO: Start using below whenever gulp-header supports sourcemaps.
|
||||||
//.pipe(header(
|
//.pipe(header(
|
||||||
// "/*\n" +
|
// "/*\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" +
|
// "** 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" +
|
// "** For more information, see the Readme.txt file in the Gulp solution folder.\n" +
|
||||||
// "*/\n\n"))
|
// "*/\n\n"))
|
||||||
.pipe(sourcemaps.write())
|
.pipe(gulpif(generateSourceMaps, sourcemaps.write()))
|
||||||
.pipe(gulp.dest(assetGroup.outputDir))
|
.pipe(gulp.dest(assetGroup.outputDir))
|
||||||
.pipe(uglify())
|
.pipe(uglify())
|
||||||
.pipe(rename({
|
.pipe(rename({
|
||||||
suffix: ".min"
|
suffix: ".min"
|
||||||
}))
|
}))
|
||||||
.pipe(gulp.dest(assetGroup.outputDir));
|
.pipe(gulp.dest(assetGroup.outputDir));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user