Convert repo to Grunt
Closed this issue · 8 comments
Convert the current custom node build script to a set of grunt-based tasks.
Greetings,
So far I've setup the initial Gruntfile.js, baseline functionality for Less + watch + css minification. I didn't upload the node dependencies, so if you want to try it out, you'll have to do an npm install in the working directory. Also have the base for image processing (not spriting, perhaps a pull request for that as well). The challenge now is porting the existing javascript processing into using the the grunt-contrib-* plugins.
Running "grunt rp"
Will currently clean, compile the less in your _src directory to css and run watch. Any time a .less file changes the watch process picks it up and triggers a re-compile. Depending on the JS, i'm wondering if this might be restructured into a temporary dev directory or a mapping of some sort so you can work with your src javascript in conjunction with the processed css.
Running "grunt build"
Will clean, compile less to css, image minification (untested with 0 images), css minification, and run the processJs task.
Currently I've "hacked" and wrapped a grunt task from the existing javascript processing in tasks/processJs.js and execute that from the Gruntfile.js. I'm thinking that this processJs.js can be ported with a combination of grunt-contrib-requirejs, grunt-contrib-copy, and grunt-contrib-uglify plugins...
-J
Awesome, I will take a look through your fork and comment there.
Edit: just going to comment here for consistency.
I think we can just create tasks for "thin" and "min". "thin" just needs to use r.js for modules and the onbuildWrite to remove the AMDness. It should also concate the files in the "thin" config profile for the core file. "min" task should just concate the files in the "min" profile. It can all be unminified, if we want to do that as a separate task.
That way we can add profiles at will like "oldIE", "oldAndroid", etc.
Cool, I think we need to write some documentation around naming conventions for the "AMD stripper" (yeah I just called it that) because I think it might be a little fragile with the global namespace. Thoughts? Maybe using the directory structure path.to.object = {};
That little snippet is managed here https://github.com/jreading/R.js-Strip-AMD. It's not much and I haven't had much problem with fragility, since AMD is specific about structure, but I'm open to anything.
Ah, I think I I know what you mean about globals. There's another piece of code in there that wraps it in an IIFE after it's stripped.
That would be the wrap: true,
in the r.js config.
I see what you mean with IIFE in r.js, thank you for sharing.
looks done at this point. Only optimizations are left.