Thursday, October 3, 2013

Do the impossible! Call one .js file from within another without any HTML being used as the bootstrapper.

Do so in GRUNT! The last bit of code here could be refactored to:

grunt.registerTask('bar', function() {
   var whatever = require('./whatever');
   whatever.somethingErOther();
});

 
 

This gives you access to the somethingErOther function kept in whatever.js which should sit in the same folder as Gruntfile.js! To empower this I think you will need to call...
grunt.loadNpmTasks('grunt-contrib-clean');
...or...
grunt.loadNpmTasks('grunt-contrib-copy');
...or...
grunt.loadNpmTasks('grunt-contrib-requirejs');
...somewhere beforehand. I'm not sure which yet.

No comments:

Post a Comment