Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Configure grunt-bower-task with Sails.js (Bootstrap + jQuery as example)
/**
* Task to pull out specific files from bower packages.
*/
module.exports = function (grunt) {
grunt.config.set('bower', {
install: {
options: {
layout: function(type, component) {
return type;
},
targetDir: './assets',
install: true,
cleanTargetDir: false,
cleanBowerDir: false
}
}
});
grunt.loadNpmTasks('grunt-bower-task');
};
{
"name": "sails-bower",
"dependencies": {
"jquery": "^2.2.0",
"bootstrap": "^3.3.6"
},
"exportsOverride": {
"bootstrap": {
"styles": "dist/css/*.min.css",
"fonts": "dist/fonts/*",
"js/dependencies": "dist/js/bootstrap.min.js"
},
"jquery": {
"js/dependencies": "dist/jquery.min.js"
}
}
}
module.exports = function (grunt) {
grunt.registerTask('default', ['bower:install', 'compileAssets', 'linkAssets', 'watch']);
};
// CSS files to inject in order
var cssFilesToInject = [
'styles/bootstrap.min.css',
'styles/bootstrap-theme.min.css',
'styles/**/*.css'
];
// Client-side javascript files to inject in order
var jsFilesToInject = [
// Load sails.io before everything else
'js/dependencies/sails.io.js',
// Dependencies like jQuery, or Angular are brought in here
'js/dependencies/jquery.min.js',
'js/dependencies/bootstrap.min.js',
'js/dependencies/**/*.js',
// All of the rest of your client-side js files
// will be injected here in no particular order.
'js/**/*.js'
];
module.exports = function(grunt) {
grunt.registerTask('prod', [
'bower:install',
'compileAssets',
'concat',
'uglify',
'cssmin',
'sails-linker:prodJs',
'sails-linker:prodStyles',
'sails-linker:devTpl',
'sails-linker:prodJsJade',
'sails-linker:prodStylesJade',
'sails-linker:devTplJade'
]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment