From project’s directory execute next command in order to install angular-templatecache
1 |
npm install gulp-angular-templatecache --save-dev |
Modify your gulpfile.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
var templateCache = require('gulp-angular-templatecache'); // <-- ADDED // ... var paths = { sass: ['./scss/**/*.scss'], templates: ['./www/templates/**/*.html'] // <-- ADDED }; // ... gulp.task('watch', ['sass', 'templates'], function() { gulp.watch(paths.sass, ['sass']); gulp.watch(paths.templates, ['templates']); // <-- ADDED }); // ... // ADDED gulp.task('templates', function(done){ gulp.src(paths.templates) .pipe(templateCache({ standalone:true, root: 'templates'})) .pipe(gulp.dest('./www/dist')) // <-- NOTE THIS DESTINATION FOLDER .on('end', done); }); // ADDED gulp.task('serve:before', ['sass', 'templates', 'watch']); // <-- RUN THESE TASKS WHEN EXECUTING "ionic serve" |
Don’t forget to reference ‘templates’ dependency in your www/js/app.js
Don’t forget to reference www/js/dist/templates.js in your index.html file.
Start debugging with
1 |
ionic serve |
Run next command to rebuild template cache
1 |
gulp templates |
i love your site artyomsokolov.com