You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
26
25
27
26
The Problem
28
27
----
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:
30
29
31
30
![simple-app][1]
32
31
@@ -40,7 +39,7 @@ Which, if we break it down into its constituents, mainly results composed of fiv
40
39
4. A container to display the currently selected detail's info.
41
40
5. A sub-component, inside the previous one, to display additional data.
42
41
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:
44
43
45
44
```
46
45
code
@@ -94,11 +93,76 @@ Aka: vue inside angular inside vue (doh!). Wait a minute: what? I know, it sound
94
93
3.**Vuex store, seamlessly shared between Angular and Vue.**
95
94
We will progressively introduce Vuex as the one source of truth to manage application state.
96
95
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.**
98
100
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.
99
101
100
102
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).
0 commit comments