简体   繁体   English

requireJS和AMD模块/文件夹组织

[英]requireJS and AMD module/folder organisation

Can someone give me advice on organising files in RequireJs, I am looking for the best practice way of doing it that will allow the most flexibility in the future. 有人可以给我有关在RequireJs中组织文件的建议吗,我正在寻找最佳实践方法,以在将来提供最大的灵活性。

my current folder structure is as below. 我当前的文件夹结构如下。 I come from a java background that is why I have called them classes (I am aware that they are objects not classes), I am willing to change this given a better suggestion. 我来自Java背景,这就是为什么我称它们为类(我知道它们是对象而不是类)的原因,在给出更好的建议的情况下,我愿意对此进行更改。

scripts
    > startup.js
    > class
        > FromAddress.js
        > ToAddress.js
        > ...
    > common
        > class
            > Address.js
            > UrlResolver.js
            > ...
    > lib
        >jquery.js
        >jquery-ui-core.js
        > ...
    > page
        > home.js
        > sitemap.js
        > ...

/scripts/startup.js contains the requirejs configuration script and loads the appropriate main script from the /scripts/page folder /scripts/startup.js包含requirejs配置脚本​​并从/scripts/page文件夹加载适当的main脚本

/scripts/class contains application specific classes /scripts/class包含应用程序特定的类

/scripts/common/class contains classes that could be shared with another projects (they will eventually reside in a separate project and be injected somehow) /scripts/common/class包含可以与其他项目共享的类(它们最终将驻留在单独的项目中并以某种方式注入)

/scripts/lib contains javascript 3rd party libraries /scripts/lib包含javascript第三方库

/scripts/page equivalent to main.js from the documentation, basically the startup script for each page in the application. /scripts/page相当于文档中的main.js ,基本上是应用程序中每个页面的启动脚本。

我发现http://boilerplatejs.org/真的很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM