This is a bug in the current sails frontend generator. I have submitted a PR, but existing applications will have to be fixed manually, since the generator is only executed once.
The issue is in the end of the current pipeline.js
file, in the section that actually exports the settings. At the moment it goes like this:
// pipeline.js
//... Defined rules ...
module.exports.cssFilesToInject = cssFilesToInject.map(function(path) {
return '.tmp/public/' + path;
});
module.exports.jsFilesToInject = jsFilesToInject.map(function(path) {
return '.tmp/public/' + path;
});
module.exports.templateFilesToInject = templateFilesToInject.map(function(path) {
return 'assets/' + path;
});
As you can see it prepends the relative path to the tmp
folder or the assets
folder for templates. This results in the rule
!js/foo.js
in .tmp/public/!js/foo.js
, which will probably not match anything.
The solution is to replace the block above in pipeline.js
with the following:
module.exports.cssFilesToInject = cssFilesToInject.map(function(path) {
var tmpPath = '.tmp/public/';
if (path.substring(0,1) == '!')
return '!' + tmpPath + path.substring(1);
return tmpPath + path;
});
module.exports.jsFilesToInject = jsFilesToInject.map(function(path) {
var tmpPath = '.tmp/public/';
if (path.substring(0,1) == '!')
return '!' + tmpPath + path.substring(1);
return tmpPath + path;
});
module.exports.templateFilesToInject = templateFilesToInject.map(function(path) {
var tmpPath = 'assets/';
if (path.substring(0,1) == '!')
return '!' + tmpPath + path.substring(1);
return tmpPath + path;
});
This will check if the given rule starts with an !
and prepend it correctly, so !js/foo.js
will result in !.tmp/public/js/foo.js
that will correctly match.
The exclusions have to be set AFTER the result set was created. This is according to grunt's documentation. So for your case it would be:
var jsFilesToInject = [
//...
'!**Gruntfile.js',
]