Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>With some help from <a href="https://groups.google.com/forum/?fromgroups=#!topic/durandaljs/sYZO79Db_JM" rel="nofollow">Durandals Google Group</a> I found a solution.</p> <p>It's not possible to use the provided optimizer.exe but it's quite easy to create a custom r.js config which can handle the setup I described in the question:</p> <p>First of all I ran the optimizer.exe which created a basic config file (app.build.js) that i used as a starting point. This config file automatically included all necessary files from the project itself (e.g. Project1).</p> <p>The only things that are missing in this config file are the references to my shared code (the login files from the ProjectsBase directory). Therefore I added them manually along with a new path.</p> <p>Custom app.build.js (3 changes highlighted with a comment, the rest is how it was built from the optizimer.exe):</p> <pre><code>{ "name": "durandal/amd/almond-custom", "inlineText": true, "stubModules": [ "durandal/amd/text" ], "paths": { "text": "durandal/amd/text", "projectsbase": "../../ProjectsBase/" // New path to folder with shared files }, "baseUrl": "ProjectsDir\\Project1\\app", "mainConfigFile": "ProjectsDir\\Project1\\app\\main.js", "include": [ "main", "durandal/app", "durandal/composition", "durandal/events", "durandal/http", "text!durandal/messageBox.html", "durandal/messageBox", "durandal/modalDialog", "durandal/system", "durandal/viewEngine", "durandal/viewLocator", "durandal/viewModel", "durandal/viewModelBinder", "durandal/widget", "durandal/plugins/router", "durandal/transitions/entrance", "projectsbase/app/models/Login", // Include for login model "models/Main", "models/Shell", "text!projectsbase/app/views/Login.html", // Include for login view "text!views/Main.html", "text!views/Shell.html" ], "exclude": [], "keepBuildDir": true, "optimize": "uglify2", "out": "ProjectsDir\\Project1\\app\\main-built.js", "pragmas": { "build": true }, "wrap": true, "insertRequire": [ "main" ] } </code></pre> <p>Now I only had to update my Shell.js to use the correct routes to the Login model &amp; view by also adding a path to requirejs and using it correctly when setting the routes:</p> <p>Add path at the very beginning of Shell.js:</p> <pre><code>requirejs.config({ paths: { 'projectsbase': '../../ProjectsBase/' } }); </code></pre> <p>Set correct routes in activate method of Shell.js:</p> <pre><code>router.map([ { url: 'Login', moduleId: 'projectsbase/app/models/Login', name:'Login', visible: true }, { url: 'Main', moduleId: 'models/Main', name:'Main', visible: true } ]); </code></pre> <p>Now i can build my main-built.js which bundles &amp; minifies all relevant files by opening the node js command line, browsing to the directory where the r.js config file is and create the build (the main-built.js) with the following command:</p> <pre><code>node r.js -o app.build.js </code></pre> <p>This way everything is included correctly when I'm working with the debug files and it's also working with the build main-built.js which also includes my shared files from the ProjectsBase.</p>
 

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