File structure for a web app using requirejs and b

2019-04-15 09:52发布

问题:

I am thinking about the best way to define a file structure for a web app using requirejs and backbone. I have two ideas (1) (2).
According to you what is the best or what would you change?


(1)

|-- vendor
     |-- js (jquery, underscore ....)
|-- images
|-- css
|-- spec
|-- templates
|-- js
|    |-- utils
|    |-- models
|    |-- collections
|    |-- views
|    conf.js
|    app.js
|    router.js
|- index.html

(2)

|-- assets
       |-- js (jquery, underscore ....)
       |-- css
       |-- images
|-- src
       |-- templates
       |-- js
            |-- views
            |-- models
            |-- collections
            |-- utils
           conf.js
           app.js
           router.js
|-- spec         
|-- index.html

回答1:

In fact, in different ways have advantages and disadvantages of different ways.The most important thing is to find a suitable way of organizing files.The following is the organization of the project I am currently doing. This way the focus will be the same module-related files are placed in a folder. For example: the people module, this module all files are placed in modules / base / people directory. After updating and maintenance of this module, only need to focus on the files in this directory on the line, will not affect files outside the directory, and improved maintainability.

I hope my answer can give you some help, I hope you some valuable advice.