I'm using grunt to compose a script that I have broken in two parts: main.js loads an inline worker, worker.js is the actual code for the inline worker.
And this means I have the following code to load the worker, inside main.js:
function setupWorker (workerCode) {
var blobBuilder = new BlobBuilder();
blobBuilder.append(workerCode);
var blob = blobBuilder.getBlob('text/javascript');
var url = URL.createObjectURL(blob);
return(url);
}
var workerURL = setupWorker('worker code, contents of worker.js');
var worker = new Worker(workerURL);
Now the question is, using Grunt, how can I substitute 'worker code, contents of worker.js' in the example, with the actual contents of worker.js ?
Am I doing this right with static code inclusion ? Should I use one of the modules for require.js ?