Note that there are some explanatory texts on larger screens.

plurals
  1. POReusing/sharing views & models in different projects with Durandal JS
    primarykey
    data
    text
    <p>I'm building multiple applications using Durandal JS. All those applications are located on the same server under the same document root and share some common code. For example they all use the same model &amp; view for login.</p> <p>How can i reuse/share the login model &amp; view in all those applications without just copy &amp; pasting the files to the projects?</p> <p>I already tried something with the following folder structure:</p> <pre><code>ProjectsDir/Project1/app/durandal/.. /models/Shell.js, Main.js, ... /views/Shell.html, Main.html, ... /main.js /main-built.js ProjectsDir/Project2/app/durandal/.. /models/Shell.js, Main.js, ... /views/Shell.html, Main.html, ... /main.js /main-built.js ProjectsDir/ProjectsBase/app/models/Login.js /views/Login.html </code></pre> <p>This way it would be possible to reference the same login model &amp; view in my ProjectsBase from all other projects by setting the correct route to it in the respective shell.js. This route could look something like this:</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>This works as expected during debugging but building the production version with the durandal optimizer unfortunately doesn't work. Actually building does work (it produces the main-built.js just fine) but when i launch the site with the production file referenced i get the following error:</p> <pre><code>Uncaught Error: undefined missing durandal/../../../MPBase/durandal-app/models/Login </code></pre> <p>I'd really appreciate any ideas on how I could make the built production file work with the setup I described above.</p> <p>Of course I'm also open for other ideas on how to make models &amp; views reusable/sharable between multiple projects.</p> <p>Thanks</p>
    singulars
    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.
    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