Add angular template cache to prevent XHR requests to fetch templates

This commit is contained in:
Kelvin 2015-06-14 16:25:42 +01:00
parent c68b007ed7
commit d0e1ef7af8
4 changed files with 24 additions and 1 deletions

View file

@ -22,7 +22,7 @@
public static function styleIncludes($area = 'app') {
if (!Config::get("app.debug"))
return '<script>document.write(\'<link rel="stylesheet" href="build/styles/' . $area . '.css?' . filemtime("build/styles/" . $area . ".css") . ' />"\');</script>';
return '<script>document.write(\'<link rel="stylesheet" href="build/styles/' . $area . '.css?' . filemtime("build/styles/" . $area . ".css") . '" />\');</script>';
$styles = self::mergeGlobs(self::getStylesForArea($area));
$retVal = "";

View file

@ -122,6 +122,10 @@
{{ Assets::scriptIncludes() }}
@if (!Config::get("app.debug"))
<script src="/build/scripts/templates.js"></script>
@endif
@yield('app_scripts')
@endsection

View file

@ -149,6 +149,24 @@ gulp.task("styles-embed", function() {
.pipe(gulp.dest("public/build/styles"));
});
gulp.task('copy:templates', function() {
gulp.src([
'public/templates/**/*.html'
])
.pipe(plug.angularTemplatecache({
module: "ponyfm",
root: "/templates"
}))
.pipe(gulp.dest('public/build/scripts'));
});
gulp.task('build', [
'scripts-app',
'styles-app',
'scripts-embed',
'styles-embed',
]);
gulp.task("watch", function() {
plug.livereload.listen();
gulp.watch("app/scripts/**/*.{coffee,js}", ["scripts-app"]);

View file

@ -9,6 +9,7 @@
"dependencies": {},
"devDependencies": {
"gulp": "^3.8.11",
"gulp-angular-templatecache": "^1.6.0",
"gulp-autoprefixer": "^2.2.0",
"gulp-cached": "^1.0.4",
"gulp-coffee": "^2.3.1",