Created
February 22, 2016 13:38
-
-
Save PascalAnimateur/dfe50ed37389fc50bb27 to your computer and use it in GitHub Desktop.
Configure grunt-bower-task with Sails.js (Bootstrap + jQuery as example)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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'); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function (grunt) { | |
grunt.registerTask('default', ['bower:install', 'compileAssets', 'linkAssets', 'watch']); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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' | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
The files should go in the following places (GitHub gist doesn't allow path in filenames):
bower.json
tasks/config/bower.js
tasks/register/default.js
tasks/register/prod.js
tasks/pipeline.js
Don't forget to install grunt-bower-task as a dev dependency using:
npm install grunt-bower-task --save-dev