Note that there are some explanatory texts on larger screens.

plurals
  1. PORequireJS with multiple pages -- using optimizer
    primarykey
    data
    text
    <p>I have my JavaScript organized as described here: <a href="https://stackoverflow.com/a/10816983/83897">https://stackoverflow.com/a/10816983/83897</a>.</p> <p>I have a JavaScript-heavy ASP.NET application that has multiple different pages (vs. being a single-page application). Each page has different dependencies, so I have a per-page .js file (page1.js, page2.js, etc.). Each has a require() call, declaring its dependencies:</p> <pre><code>require(['jquery', 'page1Module'], function($, module){ // page1 specific stuff here }); </code></pre> <p>This works fine. <strong>What I'm wondering is</strong>, how might the RequireJS build process work? I think I want a per-page "build" .js file (e.g. page1-build.js, page2-build.js, etc.)? Is there existing software I can leverage?</p> <p>The process might look like this:</p> <ol> <li>Compile all dependencies for a given script into one build.js file in a temporary directory.</li> <li>Calculate an MD5 fingerprint for the compiled file.</li> <li>Compare that fingerprint with the comparable file in public/assets.</li> <li>Create an in-memory RequireJS manifest, mapping each module to the compiled file. Append this manifest to the compiled file.</li> <li>Somehow make production use the build file.</li> </ol> <p><strong>EDIT:</strong> After some thought, I'm thinking the RequireJS optimization using node + r.js will just be part of a larger asset building process, where the asset building relies on some other, third-party library. The RequireJS optimization will simply be used for certain JavaScript dependencies (i.e. the JavaScript files for each page, including found dependencies), perhaps specified in some XML config.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload