jwhitley / requirejs-rails

RequireJS support for your Rails 3 or 4 application
MIT License
592 stars 202 forks source link

Is the optimization by r.js compile all the required modules? #223

Closed chenxeed closed 9 years ago

chenxeed commented 9 years ago

As what I understand in native requirejs, how to optimize the javascript.

We have a script, called it main.js that require some libraries, for example jquery, lodash, my_module, etc.

When we use r.js to optimize the script, it will create a minified main.js that includes all required libraries inside. It was done with uglify2 and can also generate sourcemaps.

I tried to run rake assets:precompile in my rails, and it successfully generate the build file in folder public/assets, but i don't see my main.js contain the required libraries inside, which means it still have to load asynchronously to get the modules. I'm wondering if how requirejs-rails is actually as same as what I expected with native requirejs. Any comment will be greatly appreciated.

chenxeed commented 9 years ago

Ah nevermind, after I put my file into modules in the requirejs.yml, it works well! My main.js contain all required scripts.