Ahoy the master grunt!
I want to load external configuration files in grunt so that I can do something like this:
$ grunt dev:homepage
and it will be loaded in homepage-config.json , then run watch
$ grunt dev:contact
and it will be loaded in contact-config.json , then run watch
Each configuration file will provide a specific setting for tasks: watch, jshint, concat, etc.
Inside my gruntfile, I have a task called dev
grunt.registerTask('dev', 'loads in external -config.json file, then runs watch', function(name) { grunt.initConfig(grunt.file.readJSON(name + '-config.json')); console.log(grunt.config('jshint.pageConfig.src')
Inside this dev task, external configuration loading works fine. This console.log will return what you expect, and the watch task will start working with the installation installed externally.
My problem is that as soon as watch starts the task launch, these tasks no longer have access to this external downloadable config. Somewhere between the dev task and the tasks called by watch , the dynamically loaded configuration is reset.
Can anyone shed some light on why this is happening and how I can fulfill my goal?
Thanks a lot James
James source share