With the explosion of the mobile Internet and the awkwardness of responsive pages, web and mobile projects have become standard, but there will be more.
Multi-project development is a big challenge for the front end
- Repeat, repeat front-end architecture, repeat front-end dependencies, repeat utility functions, etc
- Limitations, different background has different rules, “adapt to local conditions” really uncomfortable, just wait on good
rails
Here comes another onephp
- Optimal, back-end engineering to do front-end construction, always seems not enough “optimal”.
So, we need to separate the front-end development project, organize the code according to the front-end, and use the build tools to optimize the front-end resource files. So the new problem is, how do you manage this rapidly iterating, frequently updated front-end project?
- Managed as a separate project?
- Git submodule or Git subtree
Multiple background projects: Qdaily4_Web/Moible/APP Front-end project: qdaily4_feboierPlate
Previous development patterns
- in
qdaily4_feboierplate
Modify the front-end code in the project - build
qdaily4_feboierplate
Project, output toqdaily4_web/mobile/app
- submit
qdaily4_feboierplate
Project changes - in
qdaily4_web/mobile/app
Modify background code in the project - submit
qdaily4_web/mobile/app
Changes to the project, includingqdaily4_feboierplate
Project build output file
This development mode decouples the front-end project and the back-end project, the front-end project strictly according to the front-end code structure to organize the code, can achieve modularization, on-demand loading, the principle of proximity, image compression and other functions. The drawback is that you need to switch project submission code frequently.
In order to solve the problem of frequently switching projects, after investigating git submodule and Git subtree, we choose to use Git subtree to solve this problem.
The current development model
Qdaily4_feboierplate is a subproject of qdaily4_Web/Mobile/APP, alias appFE
- in
appfe
Modify the front-end code in the project - build
appfe
Project, output toqdaily4_web/mobile/app
- submit
qdaily4_web/mobile/app
Changes to the project (changes to the APPFE project will also be recorded) - Commit using git subtree
appfe
Changes to theqdaily4_feboierplate
After the introduction of git subtree, it no longer feels like developing two projects, no need to frequently switch project submission code, just need to use git subtree command to achieve bidirectional update of qdaily4_feboierplate project, fast development. The defect is that there are multiple copies of the qdaily4_feboierplate item.
Two-way update
The front-end project qdaily4_feboierplate is included in multiple background projects as a child Git. We realize bidirectional update of qdaily4_feboierplate through git subtree pull & Git subtree push. This is fine for modules that are unstable and need to iterate quickly.
Using Git subtree to manage front-end module projects and multiple background environment projects, it can effectively and quickly realize the rapid development of front-end module projects, two-way update, with the front-end construction system, it is absolutely cool.
tip
Git repository alias
Use appfe as [email protected]: qdaily/qdaily4_feboierplate warehouse alias
- Direct command line input:
git remote add appfe [email protected]:qdaily/qdaily4_feboierplate.gitCopy the code
- You can also configure it
.git/config
File:[remote "appfe"] url = [email protected]:qdaily/qdaily4_feboierplate fetch = +refs/heads/*:refs/remotes/appfe/*Copy the code
Git instruction customization
Git directives can be customized to make them easier to remember
- configuration
.git/config
Make git subtree commands easiergit subtree add --prefix=appfe [email protected]:qdaily/qdaily4_feboierplate.git master git subtree pull --prefix=appfe [email protected]:qdaily/qdaily4_feboierplate.git master git subtree push --prefix=appfe [email protected]:qdaily/qdaily4_feboierplate.git masterCopy the code
[alias] stadd = subtree add --prefix=appfe [email protected]:qdaily/qdaily4_feboierplate.git master stpull = subtree pull --prefix=appfe [email protected]:qdaily/qdaily4_feboierplate.git master stpush = subtree push --prefix=appfe [email protected]:qdaily/qdaily4_feboierplate.git masterCopy the code