mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-25 14:37:59 +01:00
Updated indents in the gulpfile.
This commit is contained in:
parent
b00982cd61
commit
f502cb9665
1 changed files with 148 additions and 142 deletions
288
gulpfile.js
288
gulpfile.js
|
@ -3,176 +3,182 @@ var gulp = require("gulp"),
|
||||||
argv = require("yargs").argv;
|
argv = require("yargs").argv;
|
||||||
|
|
||||||
var plumberOptions = {
|
var plumberOptions = {
|
||||||
errorHandler: plug.notify.onError("Error: <%= error.message %>")
|
errorHandler: plug.notify.onError("Error: <%= error.message %>")
|
||||||
};
|
};
|
||||||
|
|
||||||
gulp.task("scripts-app", function() {
|
gulp.task("scripts-app", function () {
|
||||||
var paths = [
|
var paths = [
|
||||||
"resources/assets/scripts/app/**/*.{coffee,js}",
|
"resources/assets/scripts/app/**/*.{coffee,js}",
|
||||||
"resources/assets/scripts/base/**/*.{coffee,js}",
|
"resources/assets/scripts/base/**/*.{coffee,js}",
|
||||||
"resources/assets/scripts/shared/**/*.{coffee,js}"
|
"resources/assets/scripts/shared/**/*.{coffee,js}"
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!argv.production) {
|
if (!argv.production) {
|
||||||
paths.push("resources/assets/scripts/debug/**/*.{coffee,js}");
|
paths.push("resources/assets/scripts/debug/**/*.{coffee,js}");
|
||||||
|
|
||||||
// we also want to add the embed stuff, since we're in development mode
|
// we also want to add the embed stuff, since we're in development mode
|
||||||
// we want to watch embed files and re-compile them. However, we want
|
// we want to watch embed files and re-compile them. However, we want
|
||||||
// to leave this path out in production so that embed files are not bloating
|
// to leave this path out in production so that embed files are not bloating
|
||||||
// the js file
|
// the js file
|
||||||
paths.push("resources/assets/scripts/embed/**/*.{coffee,js}");
|
paths.push("resources/assets/scripts/embed/**/*.{coffee,js}");
|
||||||
}
|
}
|
||||||
|
|
||||||
return argv.production
|
return argv.production
|
||||||
// Production pipeline
|
// Production pipeline
|
||||||
? gulp.src(paths, {base: "resources/assets/scripts"})
|
? gulp.src(paths, {base: "resources/assets/scripts"})
|
||||||
.pipe(plug.plumber(plumberOptions))
|
.pipe(plug.plumber(plumberOptions))
|
||||||
.pipe(plug.order([
|
.pipe(plug.order([
|
||||||
"resources/assets/scripts/base/jquery-2.0.2.js",
|
"resources/assets/scripts/base/jquery-2.0.2.js",
|
||||||
"resources/assets/scripts/base/angular.js",
|
"resources/assets/scripts/base/angular.js",
|
||||||
"resources/assets/scripts/base/*.{coffee,js}",
|
"resources/assets/scripts/base/*.{coffee,js}",
|
||||||
"resources/assets/scripts/shared/*.{coffee,js}",
|
"resources/assets/scripts/shared/*.{coffee,js}",
|
||||||
"resources/assets/scripts/app/*.{coffee,js}",
|
"resources/assets/scripts/app/*.{coffee,js}",
|
||||||
"resources/assets/scripts/app/services/*.{coffee,js}",
|
"resources/assets/scripts/app/services/*.{coffee,js}",
|
||||||
"resources/assets/scripts/app/filters/*.{coffee,js}",
|
"resources/assets/scripts/app/filters/*.{coffee,js}",
|
||||||
"resources/assets/scripts/app/directives/*.{coffee,js}",
|
"resources/assets/scripts/app/directives/*.{coffee,js}",
|
||||||
"resources/assets/scripts/app/controllers/*.{coffee,js}",
|
"resources/assets/scripts/app/controllers/*.{coffee,js}",
|
||||||
"resources/assets/scripts/**/*.{coffee,js}"
|
"resources/assets/scripts/**/*.{coffee,js}"
|
||||||
], {base: "."}))
|
], {base: "."}))
|
||||||
.pipe(plug.if(/\.coffee/, plug.coffee()))
|
.pipe(plug.if(/\.coffee/, plug.coffee()))
|
||||||
.pipe(plug.concat("app.js"))
|
.pipe(plug.concat("app.js"))
|
||||||
.pipe(plug.uglify())
|
.pipe(plug.uglify())
|
||||||
.pipe(gulp.dest("public/build/scripts"))
|
.pipe(gulp.dest("public/build/scripts"))
|
||||||
// Development/watch pipeline
|
// Development/watch pipeline
|
||||||
: gulp.src(paths, {base: "resources/assets/scripts"})
|
: gulp.src(paths, {base: "resources/assets/scripts"})
|
||||||
.pipe(plug.plumber(plumberOptions))
|
.pipe(plug.plumber(plumberOptions))
|
||||||
.pipe(plug.cached('scripts'))
|
.pipe(plug.cached('scripts'))
|
||||||
.pipe(plug.sourcemaps.init())
|
.pipe(plug.sourcemaps.init())
|
||||||
.pipe(plug.if(/\.coffee/, plug.coffee()))
|
.pipe(plug.if(/\.coffee/, plug.coffee()))
|
||||||
.pipe(plug.sourcemaps.write({
|
.pipe(plug.sourcemaps.write({
|
||||||
includeContent: false,
|
includeContent: false,
|
||||||
sourceRoot: "/dev-scripts/"
|
sourceRoot: "/dev-scripts/"
|
||||||
}))
|
}))
|
||||||
.pipe(gulp.dest("public/build/scripts"));
|
.pipe(gulp.dest("public/build/scripts"));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("scripts-embed", function() {
|
gulp.task("scripts-embed", function () {
|
||||||
// note that this task should really only ever be invoked for production
|
// note that this task should really only ever be invoked for production
|
||||||
// since development-mode watches and builds include the embed scripts
|
// since development-mode watches and builds include the embed scripts
|
||||||
// already
|
// already
|
||||||
|
|
||||||
var includedScripts = [
|
var includedScripts = [
|
||||||
"resources/assets/scripts/base/jquery-2.0.2.js",
|
"resources/assets/scripts/base/jquery-2.0.2.js",
|
||||||
"resources/assets/scripts/base/jquery.viewport.js",
|
"resources/assets/scripts/base/jquery.viewport.js",
|
||||||
"resources/assets/scripts/base/underscore.js",
|
"resources/assets/scripts/base/underscore.js",
|
||||||
"resources/assets/scripts/base/moment.js",
|
"resources/assets/scripts/base/moment.js",
|
||||||
"resources/assets/scripts/base/jquery.timeago.js",
|
"resources/assets/scripts/base/jquery.timeago.js",
|
||||||
"resources/assets/scripts/base/soundmanager2-nodebug.js",
|
"resources/assets/scripts/base/soundmanager2-nodebug.js",
|
||||||
"resources/assets/scripts/embed/*.coffee"
|
"resources/assets/scripts/embed/*.coffee"
|
||||||
];
|
];
|
||||||
|
|
||||||
return gulp.src(includedScripts, {base: "resources/assets/scripts"})
|
return gulp.src(includedScripts, {base: "resources/assets/scripts"})
|
||||||
.pipe(plug.plumber(plumberOptions))
|
.pipe(plug.plumber(plumberOptions))
|
||||||
.pipe(plug.if(/\.coffee/, plug.coffee()))
|
.pipe(plug.if(/\.coffee/, plug.coffee()))
|
||||||
.pipe(plug.order(includedScripts, {base: "."}))
|
.pipe(plug.order(includedScripts, {base: "."}))
|
||||||
.pipe(plug.concat("embed.js"))
|
.pipe(plug.concat("embed.js"))
|
||||||
.pipe(plug.uglify())
|
.pipe(plug.uglify())
|
||||||
.pipe(gulp.dest("public/build/scripts"));
|
.pipe(gulp.dest("public/build/scripts"));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("styles-app", function() {
|
gulp.task("styles-app", function () {
|
||||||
var includedStyles = [
|
var includedStyles = [
|
||||||
"resources/assets/styles/base/jquery-ui.css",
|
"resources/assets/styles/base/jquery-ui.css",
|
||||||
"resources/assets/styles/base/colorbox.css",
|
"resources/assets/styles/base/colorbox.css",
|
||||||
"resources/assets/styles/app.less"
|
"resources/assets/styles/app.less"
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!argv.production) {
|
if (!argv.production) {
|
||||||
includedStyles.push("resources/assets/styles/profiler.less");
|
includedStyles.push("resources/assets/styles/profiler.less");
|
||||||
includedStyles.push("resources/assets/styles/prettify.css");
|
includedStyles.push("resources/assets/styles/prettify.css");
|
||||||
|
|
||||||
// we also want to add the embed stuff, since we're in development mode
|
// we also want to add the embed stuff, since we're in development mode
|
||||||
// we want to watch embed files and re-compile them. However, we want
|
// we want to watch embed files and re-compile them. However, we want
|
||||||
// to leave this path out in production so that embed files are not bloating
|
// to leave this path out in production so that embed files are not bloating
|
||||||
// the css file
|
// the css file
|
||||||
includedStyles.push("resources/assets/styles/embed.css");
|
includedStyles.push("resources/assets/styles/embed.css");
|
||||||
|
|
||||||
// Remove app.less from the cache so that it gets recompiled
|
// Remove app.less from the cache so that it gets recompiled
|
||||||
var styleCache = plug.cached.caches.styles;
|
var styleCache = plug.cached.caches.styles;
|
||||||
for (var file in styleCache) {
|
for (var file in styleCache) {
|
||||||
if (!styleCache.hasOwnProperty(file))
|
if (!styleCache.hasOwnProperty(file))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!endsWith(file, "app.less"))
|
if (!endsWith(file, "app.less"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
delete styleCache[file];
|
delete styleCache[file];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// note that we're not doing autoprefixer on dev builds for now to shave off roughly 600-700 milliseconds per
|
// note that we're not doing autoprefixer on dev builds for now to shave off roughly 600-700 milliseconds per
|
||||||
// build. It's already taking forever to recompile the less
|
// build. It's already taking forever to recompile the less
|
||||||
|
|
||||||
return argv.production
|
return argv.production
|
||||||
// Production pipeline
|
// Production pipeline
|
||||||
? gulp.src(includedStyles, {base: "resources/assets/styles"})
|
? gulp.src(includedStyles, {base: "resources/assets/styles"})
|
||||||
.pipe(plug.plumber(plumberOptions))
|
.pipe(plug.plumber(plumberOptions))
|
||||||
.pipe(plug.if(/\.less/, plug.less()))
|
.pipe(plug.if(/\.less/, plug.less()))
|
||||||
.pipe(plug.autoprefixer({browsers: ["last 2 versions"], cascade: false}))
|
.pipe(plug.autoprefixer({
|
||||||
.pipe(plug.concat("app.css"))
|
browsers: ["last 2 versions"],
|
||||||
.pipe(plug.minifyCss())
|
cascade: false
|
||||||
.pipe(gulp.dest("public/build/styles"))
|
}))
|
||||||
// Development pipeline
|
.pipe(plug.concat("app.css"))
|
||||||
: gulp.src(includedStyles, {base: "resources/assets/styles"})
|
.pipe(plug.minifyCss())
|
||||||
.pipe(plug.plumber(plumberOptions))
|
.pipe(gulp.dest("public/build/styles"))
|
||||||
.pipe(plug.cached("styles"))
|
// Development pipeline
|
||||||
.pipe(plug.sourcemaps.init())
|
: gulp.src(includedStyles, {base: "resources/assets/styles"})
|
||||||
.pipe(plug.if(/\.less/, plug.less()))
|
.pipe(plug.plumber(plumberOptions))
|
||||||
.pipe(plug.sourcemaps.write({
|
.pipe(plug.cached("styles"))
|
||||||
includeContent: false,
|
.pipe(plug.sourcemaps.init())
|
||||||
sourceRoot: "/dev-styles/"
|
.pipe(plug.if(/\.less/, plug.less()))
|
||||||
}))
|
.pipe(plug.sourcemaps.write({
|
||||||
.pipe(gulp.dest("public/build/styles"))
|
includeContent: false,
|
||||||
.pipe(plug.livereload());
|
sourceRoot: "/dev-styles/"
|
||||||
|
}))
|
||||||
|
.pipe(gulp.dest("public/build/styles"))
|
||||||
|
.pipe(plug.livereload());
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("styles-embed", function() {
|
gulp.task("styles-embed", function () {
|
||||||
// note that this task should really only ever be invoked for production
|
// note that this task should really only ever be invoked for production
|
||||||
// since development-mode watches and builds include the embed styles
|
// since development-mode watches and builds include the embed styles
|
||||||
// already
|
// already
|
||||||
|
|
||||||
return gulp.src(["resources/assets/styles/embed.less"], {base: "resources/assets/styles"})
|
return gulp.src(["resources/assets/styles/embed.less"], {base: "resources/assets/styles"})
|
||||||
.pipe(plug.less())
|
.pipe(plug.less())
|
||||||
.pipe(plug.autoprefixer({browsers: ["last 2 versions"], cascade: false}))
|
.pipe(plug.autoprefixer({
|
||||||
.pipe(plug.concat("embed.css"))
|
browsers: ["last 2 versions"],
|
||||||
.pipe(plug.minifyCss())
|
cascade: false
|
||||||
.pipe(gulp.dest("public/build/styles"));
|
}))
|
||||||
|
.pipe(plug.concat("embed.css"))
|
||||||
|
.pipe(plug.minifyCss())
|
||||||
|
.pipe(gulp.dest("public/build/styles"));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('copy:templates', function() {
|
gulp.task('copy:templates', function () {
|
||||||
gulp.src([
|
gulp.src([
|
||||||
'public/templates/**/*.html'
|
'public/templates/**/*.html'
|
||||||
])
|
])
|
||||||
.pipe(plug.angularTemplatecache({
|
.pipe(plug.angularTemplatecache({
|
||||||
module: "ponyfm",
|
module: "ponyfm",
|
||||||
root: "/templates"
|
root: "/templates"
|
||||||
}))
|
}))
|
||||||
.pipe(gulp.dest('public/build/scripts'));
|
.pipe(gulp.dest('public/build/scripts'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('build', [
|
gulp.task('build', [
|
||||||
'scripts-app',
|
'scripts-app',
|
||||||
'styles-app',
|
'styles-app',
|
||||||
'scripts-embed',
|
'scripts-embed',
|
||||||
'styles-embed',
|
'styles-embed',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
gulp.task("watch", function() {
|
gulp.task("watch", function () {
|
||||||
plug.livereload.listen();
|
plug.livereload.listen();
|
||||||
gulp.watch("resources/assets/scripts/**/*.{coffee,js}", ["scripts-app"]);
|
gulp.watch("resources/assets/scripts/**/*.{coffee,js}", ["scripts-app"]);
|
||||||
gulp.watch("resources/assets/styles/**/*.{css,less}", ["styles-app"]);
|
gulp.watch("resources/assets/styles/**/*.{css,less}", ["styles-app"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
function endsWith(str, suffix) {
|
function endsWith(str, suffix) {
|
||||||
return str.indexOf(suffix, str.length - suffix.length) !== -1;
|
return str.indexOf(suffix, str.length - suffix.length) !== -1;
|
||||||
}
|
}
|
Loading…
Reference in a new issue