-
Notifications
You must be signed in to change notification settings - Fork 339
common errors
Probably the most annoying issue for any grunt user. It's not an easy issue to fix but has nothing to do with grunt-usemin
, it's a javascript error.
You are using template strings in your configuration, which means that you have used this kind of string <%= foo %>
.
What grunt
tells you is that it failed to process a template, found in your configuration. The not-so-cryptic-but-hard-to-understand warning message is:
Warning: An error occurred while processing a template ([error message]). Use --force to continue.
grunt.template.process
delegates to _.template
to replaces the template string with your data and something bad happens. The important part is the [error message]
part which is the javascript error. You might see (Cannot read property 'options' of undefined)
, which means that your template is something like <%= variable.options %>
where variable
is undefined
.
-
typo: check that there is no typo in your template string. Using
<%= pkg.verion %>
instead of<%= pkg.version %>
. -
unknow value: when using
<%= pkg.version %>
in your configuration have you added an keypkg
in your grunt configuration which should be an object with a property version.grunt.init({ // ... pkg: { version: '1.2.3' }, // or better pkg: grunt.file.readJSON('package.json'), // ... });
- option value only defined at runtime: probably the most tricky issue. You might think that grunt will parse your configuration and set the option value at runtime while it might not be the case. It depends on your configuration and the tasks used. You might be able to use a function for a task option, if supported, to fix the value undefined at runtime.