Frage

I have a nice setup of require.js + r.js. Right now, i seem to have a "one or the other" choice between these two:

  • Use name + out options to just create one js-file, nothing else
  • Use appDir + dir options which will copy over ALL the files from appDir to dir

The second option is what i am currently using. This will, howeever, copy and minify a lot of files that are actually included in my compiled main.js. Those files will never actually be loaded.

Does r.js have some option to just skip over files that are part of the minification-process?

An Illustratrion

Let's pretend I have these files in appDir:

index.html
main.js
lib/
  - libA.js (dependency of main, will be loaded by require.js)
  - libB.js (dependency of main, will be loaded by require.js)
  - libC.js (loaded any other way)
img/
  - imgA.png
  - imgB.png

The first option (name+out) will just yield a huge uglified main.js.

main.js

The second option (appDir+dir) will create something like this in dir/

index.html
main.js (uglified)
lib/
  - libA.js (uglified and will never be loaded)
  - libB.js (uglified and will never be loaded)
  - libC.js (uglified and used)
img/
  - imgA.png
  - imgB.png

What i would ACTUALLY like is this:

index.html
main.js
lib/
  - libC.js (no libA.js / libB.js)
img/
  - imgA.png
  - imgB.png

(so without the libs that are included in main.js anyway).

War es hilfreich?

Lösung

It seems to me removeCombined is the option you want. From the file that lists all options:

//If set to true, any files that were combined into a build bundle will be
//removed from the output folder.
removeCombined: false,

The false value there shows the default.

By the way, it is really worth going through this file and looking at all the options because the page that introduces the optimizer is not by any means covering them all. Going through it again recently, I discovered an option that was added in the latest release of RequireJS.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top