Skip to content

Commit ae8eb1c

Browse files
committed
directory structure
1 parent 126f8c3 commit ae8eb1c

File tree

7 files changed

+69
-5
lines changed

7 files changed

+69
-5
lines changed

README.md

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
----
33

44

5-
Migrating an Angular 1.x app to Vue
6-
=====================
5+
# Migrating an Angular 1.x app to Vue
76
> Github repository: https://github.com/arcadeJHS/AngularVueIntegration.
87
98
Sometimes you have to say "stop!" and decide it's time to migrate to a warmer and sunnier place.
@@ -26,7 +25,7 @@ Maybe it could be helpful to someone else, or maybe someone will address me to a
2625

2726
The Problem
2827
----
29-
We've got a huge legacy app, five or six years worth of coding in Angular 1.x, whose layout may be schematically represented as in this picture:
28+
We've got a huge legacy single-page app, five or six years worth of coding in Angular 1.x, whose layout may be schematically represented as in this picture:
3029

3130
![simple-app][1]
3231

@@ -40,7 +39,7 @@ Which, if we break it down into its constituents, mainly results composed of fiv
4039
4. A container to display the currently selected detail's info.
4140
5. A sub-component, inside the previous one, to display additional data.
4241

43-
At this point our applications is simply organized according to the following structure:
42+
At this point our applications is simply organized according to the following directory structure:
4443

4544
```
4645
code
@@ -94,11 +93,76 @@ Aka: vue inside angular inside vue (doh!). Wait a minute: what? I know, it sound
9493
3. **Vuex store, seamlessly shared between Angular and Vue.**
9594
We will progressively introduce Vuex as the one source of truth to manage application state.
9695

97-
4. **A module bundler.**
96+
4. **vue-router**.
97+
We would like to introduce client side routing, to facilitate view switching.
98+
99+
5. **A module bundler.**
98100
We will make use of ES6+ javascript and modules, a CSS preprocessor, and will bundle our transpiled code to include it in the existing application. Webpack at rescue here.
99101

100102

103+
So what?
104+
----
105+
A lot to do, so many things to understand, and to fit into each other.
106+
107+
> "Me and my brother Vue here,
108+
> We was hitchhikin' down a long and lonesome road.
109+
> All of a sudden, there shined a shiny demon."
110+
111+
[ngVue][4] enters here.
112+
113+
> "ngVue is an Angular module that allows you to develop/use Vue components in AngularJS applications."
114+
115+
Cool: I am a really bad swimmer, but at least a bridge exists. I can write a Vue component and include it into the existing Angular application. That's a good start.
116+
Angular, Vue, ngVue (and Webpack). The Three Musketeers!
117+
118+
119+
Enlightening the path
120+
----
121+
Alien teaches us that the best way to generate a new creature is incubating it from the inside.
122+
To avoid side effects, I would like to preserve things as they are, as much as possible. I would like to isolate the source code I am going to add, and transpile it in a form I can use into the existing.
123+
So i create a nest for Vue in the form of a new folder, let's call it "vueApp":
124+
125+
```
126+
code
127+
|_vueApp
128+
|_angularApp
129+
|_vendor
130+
|_index.html
131+
```
132+
133+
Ideally the "vueApp" folder will contain everything related to the migration: Vue code, Vue-Angular temporary hybrid code, Webpack and package.json configurations, node_modules, and the final "production ready dist" byproduct.
134+
Furthermore, I want to keep Vue and hybrid code separated, to be able to delete no more useful Angular code in the future. For a similar reason, I create a "DEV" folder also, which contains mockups or everything useful to webpack-dev-server only. Adding a bunch of styles assets we then finally come to a developmnet ready directory structure, which, in the end, will be similar to the following:
135+
136+
```
137+
code
138+
|_vueApp
139+
|_dist
140+
| |_css
141+
| |_js
142+
|_node_modules
143+
|_src
144+
| |_assets
145+
| | |_styles
146+
| |_DEV
147+
| |_vueCode
148+
| |_ngVueBridgeCode
149+
| |_index.html
150+
| |_index.js
151+
|_.babelrc
152+
|_jest.conf.js
153+
|_package.json
154+
|_webpack.config.js
155+
|_angularApp
156+
|_vendor
157+
|_index.html
158+
```
159+
160+
> **Please note:** here I will not initialize the Vue app through vue-cli. I am reusing a Webpack custom configuration which suites my needs. Nevertheless, everything should work the same way if you are using vue-cli.
161+
162+
See tag **"tag-02-app-directory-structure"** (with emtpy folders and files).
163+
101164

102165
[1]: screenshots/01-simple_app.png
103166
[2]: screenshots/02-app_components.png
104167
[3]: screenshots/03-ng_vue_components.png
168+
[4]: https://github.com/ngVue/ngVue

code/vueApp/.babelrc

Whitespace-only changes.

code/vueApp/jest.conf.js

Whitespace-only changes.

code/vueApp/package.json

Whitespace-only changes.

code/vueApp/src/index.html

Whitespace-only changes.

code/vueApp/src/index.js

Whitespace-only changes.

code/vueApp/webpack.config.js

Whitespace-only changes.

0 commit comments

Comments
 (0)