How to build Flex projects with Grunt
With the decline of Flash in the web, sometimes it can be hard to find the tools for it in modern platforms, such as Node. That happened with me when I was preparing a Grunt build script for FlashWarp and discovered that there is no Node package for building Flash SWC libraries. And so I made it myself - grunt-compc, a Grunt plugin that can build SWC files with the compc
compiler from the Flex SDK. It depends on node-flex-sdk, so you can use it alongside with grunt-mxmlc, grunt-asdoc and other Flash tools for Node out there.
Installing Flash tools
The first thing to do to make your Grunt project Flash-enabled is to install the Flex SDK:
npm install flex-sdk@4.6.0 --save-dev
You can find the complete list of available SDK versions here.
The next thing to do is to install packages that provide wrappers for Flash compilers:
npm install grunt-mxmlc –save-dev
npm install grunt-compc –save-dev
And you are ready to go.
Configuring Grunt
Let’s assume that your Flex project consists of two parts: a library and a Flex app. In this case, your Grunt code for building that application could look like this:
1 | compc: { |
You can find the complete example project here.