shimney-sweeper
Housekeep your shimney with grunt.
install with npm
If you haven't used grunt before, be sure to check out the Getting Started guide.
From the same directory as your project's Gruntfile and package.json, install this plugin with the following command:
npm install grunt-shimney-sweeper --save-dev
Once that's done, add this line to your project's Gruntfile:
grunt.loadNpmTasks('grunt-shimney-sweeper');
If the plugin has been installed correctly, running grunt --help
at the command line should list the newly-installed plugin's task or tasks. In addition, the plugin should be listed in package.json as a devDependency
, which ensures that it will be installed whenever the npm install
command is run.
usage
grunt sweepout
reads all your installed shimney packages exports them and writes a config for them.
grunt sweep-config
reads all your installed shimney packages from npm and writes your config to www/js/config.js
.
grunt merge-configs
merges serval requirejs configuration together, into a new config file. The config file might be a module as a template and the merge of all configs can be adjusted
use
grunt.initConfig({
"sweep-config": {
www: {
options: {
configFile: "www/js/config.js",
nodeModulesUrl: "../../"
}
}
},
"sweepout": {
test: {
options: {
}
}
},
"merge-configs": {
rjsboot: {
options: {
targetFile: 'build/js/boot.js',
configFiles: [
'www/js/mylibrary/config.js',
'www/js/config.js'
]
modify: function(mergedConfig) {
return { paths: {'user': 'overriden'} };
}
template: 'resources/config-template.js',
}
}
}
});
in your Gruntfile.js
to configure the sweeper.
your config-template.js
used in merge-configs could be like this:
var require = {
}
if (typeof(requirejs) === "function") {
requirejs.config(require);
}
This allows you to use the merged config before loading requirejs (recommended if you change the baseUrl) or as a data-main attribute in requirejs.
Migration
1.0.0 => 1.1.0
- change
config
option into configFile
1.0.0 => 1.2.0
- commands are now: sweepout, sweep-config, merge-configs
- all commands are multi tasks