Closed ericclemmons closed 10 years ago
@ericclemmons I'm getting the following error now:
Running "ngtemplates:dist" (ngtemplates) task
File resources/views.js created.
>> Concat target not found: generated.files[3]
@ericclemmons nevermind, that was due to a leftover concat
property
@ericclemmons Not getting any errors now, but it doesn't seem like it's actually getting concatenated to application.js
@pheuter I assume @ericclemmons have to fix this issue first to make it work :)
I'm confused about the status of this issue. It appears that @ericclemmons fixed something in #44 which should have fixed @pheuter's use case.
@pheuter - are you saying that it doesn't?
I attempted to fix it in #44, but there was another edge case to be resolved here ;) The good news is, this will be BC-compatible with 0.4.x
I'm currently trying to set it up using v0.5.0 and I'm getting Concat target not found: scripts/scripts.js
error. I guess I should just wait for usemin
option then? :)
Wait, everyone just wait! :) Go to #63 now. concat
works with legit concat targets, but usemin screwed the pooch with how they're doing things now. =/
tl;dr If you just create a sigle js file with usemin use generated
as concat target.
@szimek You have to use generated
as concat target:
ngtemplates: {
dist: {
cwd: '<%= yeoman.app %>',
src: 'views/**.html',
dest: '<%= yeoman.dist %>/scripts/templates.js',
options: {
module: 'app', // Can replace ngtemplates.dist with ngtemplates.app
concat: 'generated',
// htmlmin: { collapseWhitespace: true, collapseBooleanAttributes: true },
htmlmin: {}
}
}
},
But this will concat templates for all js groups.
@marcalj Thanks, but unfortunately I've got 2 js groups... Also I've just noticed that I've got rev
task running after ngtemplates
...
Yep, let's wait for this issue to get fixed, then. Everyone be sure to thank grunt-usemin for changing how it builds concat targets now!
Here's a small snippet that adds usemin
option:
if (options.usemin) {
var _ = grunt.util._;
var config = grunt.config('concat');
var prefix = '.tmp/concat/';
var files = _.find(config.generated.files, function (item) {
return item.dest === prefix + options.usemin;
});
files.src.push(file.dest);
grunt.config('concat', {
generated: { files: config.generated.files }
});
}
It doesn't handle errors (i.e. invalid path to destination file in concat configuration) and I'm not sure how to read prefix
path from usemin
configuration, but it works. It doesn't solve the issue that usemin
updates paths in HTML files to files renamed by rev
after these HTML files are processed by ngtemplates
.
Here's commit with these changes: https://github.com/szimek/grunt-angular-templates/commit/1235cd40f0f5a2baa87ae666cf2d9eb1368bfc66
Just released v0.4.10
& v0.5.1
to be effectively the same thing, which adds a usemin
option. Check out the updated README & release!
@ericclemmons Thanks Eric! Much appreciated. :+1:
@ericclemmons Works perfectly! Excellent job! :)
I'll leave this here in case someone is looking into how make grunt-rev
work with grunt-angular-templates
https://github.com/yeoman/grunt-usemin/issues/235#issuecomment-33266949
From @pheuter:
In which case, the jump to
0.5.0
may not be warranted (whoops!), because this solution can let someone specifyusemin: 'javascripts/application.js'
to target that specificdest
.concat
is useful if you have a specific concat task, but trying to target what usemin generates forconcat
is annoying at best.