file watcher to make a require.js build?

I was wondering if anyone has already figured out how to make a file watcher for building a require.js build? I'm guessing it should be possible, but I can't quite figure out how to fill in the various fields for the file watcher.

1 comment

Right, to answer my own question, here's how to set it up:

File type:
Javascript Files

Scope:
Define a custom scope that excludes the generated file, because otherwise you'll end up in a loop

Program:
Point it to node_modules/requirejs/bin/r.js

Arguments:
Enter all r.js parameters you need. Most likely this is at least "-o config.js" (without the quotes)
it's also useful to put "generateSourceMaps=true preserveLicenseComments=false" here, so you have source maps available for debugging in your dev environment

Working directory:
Not really needed, but set it to somewhere in your project dir

Environment variables:
Not needed

Output Paths:
The path where you want to store the generated file. If it's inside your project scope, make sure to exclude it in a the scope definition at the top

Uncheck "Immediate File Synchronisation" at the top, otherwise you'll trigger a build with each keypress in a JS file, which will basically kill WebStorm.

0

Please sign in to leave a comment.