2

I have this build.js file:

({
    appDir: './',
    baseUrl: './js',
    dir: './dist',
    modules: [
        {
            name: 'main'
        }
    ]
})

And in my index.html I have:

<script data-main="js/main" src="js/lib/require/require.js"></script>

When I optimize the application using:

node r.js -o build.js

All the app directory is copies into dist directory. This method is really convenient since I don't need to do any changes and I can deploy the project immediately after the optimization.

The problem is that my code uses require.js which cause overhead. How can I integrate Almond? I still with the app directory will be copied into dist directory but I don't want to edit my index.html after each optimization call.
Is there a way to integrate almond?

Naor
  • 23,465
  • 48
  • 152
  • 268
  • 1
    If you want to set up almond, the [readme](https://github.com/jrburke/almond#readme) explains it all pretty well. Once you've done that, I guess you just need to script something that will replace your script tag with something like ``. I don't think you can do that programmatically using `r.js`. – c24w Apr 19 '13 at 13:53
  • @c24w: I am looking for something that set the output file. This way I can ask r.js to rewrite require.js to include the optimized code and this way I wouldn't need to change index.html. – Naor Apr 19 '13 at 16:13
  • Most serious build tools probably have search-and-replace functionality; `Grunt` seems to be a popular build tool for JS projects. It has lots of plugins, [>this one<](https://npmjs.org/package/grunt-requirejs-jzaefferer) promises doing the very thing you're trying to achieve (I never tried Grunt, though). – kryger May 08 '13 at 18:38

0 Answers0