I'm attempting to set up my sails app to use Browserify (which is working fine). However, I want to not have the non-browserified files automagically injected into my web page.
In my tasks/pipeline.js file I've attempted this (my js files that need to be browserified are in he browserify directory):
// Client-side javascript files to inject in order
// (uses Grunt-style wildcard/glob/splat expressions)
var jsFilesToInject = [
// Load sails.io before everything else
'js/dependencies/sails.io.js',
// Dependencies like jQuery, or Angular are brought in here
'js/dependencies/**/*.js',
// All of the rest of your client-side js files
// will be injected here in no particular order.
'js/**/*.js',
// Ignore browserify directory
'!js/browserify/**/*'
];
This however is not working and my non-browserified files are being injected into the web page. I'm new to Sails, so it's highly likely that this isn't the correct way to achieve this at all. Any advice would be greatly appreciated.
Its actually rather easy, simply do not put ** there. The ** wildcard means recursive search. What I'd do is the following:
var jsFilesToInject = [
// Load sails.io before everything else
'js/dependencies/sails.io.js',
// Dependencies like jQuery, or Angular are brought in here
'js/dependencies/**/*.js',
// All of the rest of your client-side js files
// will be injected here in no particular order.
'js/*.js', //all files directly in .js folder will be included, but any folders not specified above will not
];
Then if you add a folder to js directory that you actually WANT to include, simply make sure to specify it above between dependencies and last line like
'js/folderIWantToInclude/**/*.js'
Do not forget, that grunt copies all files to .tmp and sometimes you need to manually clear it out for changes like this to take effect. I also recommend visiting Grunt Configuration file docs for reference - it is grunt that does this inclusion, not sails.