miickel / gulp-angular-templatecache

Concatenates and registers AngularJS templates in the $templateCache.
MIT License
525 stars 103 forks source link

on generation, second file's templateFooter becomes ".no" #83

Closed maxmarkus closed 9 years ago

maxmarkus commented 9 years ago

We've got a really strange problem here, the angular.module ending of the second processed file is suddenly .no instead of ); Sometimes it works, but sometimes not. Cannot really reproduce it, seems more to be a bit of luck.

Outcome:

... <div data-ng-if=\"registerevent === \'success\'\" data-ng-include=\"\'public/js/app/account/templates/response.html\'\">\n    </div>\n  </article>\n</div>".no
$templateCache.put("public/js/app/account/templates/create-project.html","<div class=\"marketplace project\">\n    <article id=\"page\" class=\"page container-fluid\">\n        

Implementation

// Gulp task for creating template cache
gulp.task('html2js', function() {
    var config = {
        htmltemplates: bases.dev + paths.js + 'app/**/*.html',
        templateCache: {
            file: 'templates.js',
            options: {
                module: 'ds.templates',
                root: 'public/js/app/',
                standalone: true
            }
        }
    };
    return gulp
        .src(config.htmltemplates)
        .pipe(plumber({
            errorHandler: onError
        }))
        .pipe(templateCache(
            config.templateCache.file,
            config.templateCache.options
        ))
        .pipe(plumber.stop())
        .pipe(gulp.dest(bases.tmp));
});

Versions: gulp-angular-templatecache: 1.6.0 gulp: 3.8.8 node: 0.12.0

Any ideas how to tackle that thing?

Regards, Markus

maxmarkus commented 9 years ago

Just recognised that if I run gulp html2js standalone, it works. But using my npm start process which does minification of js, css, jshinting, concatenation and injection, it adds the .no. Weird. Have to investigate.

maxmarkus commented 9 years ago

Tracked it down to a completely different task - to the sourcemaps.init() of a less processing task.

.pipe(sourcemaps.init())
.pipe(less())
.pipe(sourcemaps.write())

Funny thing is, we have 2 less processing tasks using gulp-sourcemaps. As soon as I remove one of the sourcemaps.init(), it works smoothly.

Seems sourcemaps has a problem running twice (I have even required('gulp-sourcemaps') with 2 different instances) and somehow affects gulp-angular-translate.

miickel commented 9 years ago

Ok, thanks for the info!