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
* Required parameter for the cli core generator when vue-router is used
32
-
3. Is this a brand new project? (Default: No)
33
-
* By choosing `No`, which is the default, the plugin will try and be as non-destructive as possible to an existing project. It will do this by adding a folder into root named `ns-example` and add files into there to provide examples of how a project would change.
32
+
3. Is this a brand new project? (Default: Yes)
33
+
* By choosing `No`, the plugin will try and be as non-destructive as possible to an existing project. It will do this by adding a folder into root named `ns-example` and add files into there to provide examples of how a project would change.
34
34
* These changes will factor in answers to the other questions and adjust accordingly. Regardless of the answer, the plugin will install packages and adjust `package.json` as necessary to prep the project.
35
35
4. Dual Native AND Web development experience or a Native only? (Default: Dual)
36
-
* By default, the plugin will assume you want to develop for the Web and Native environments within the same project. As such, there will be two sides to the project where web environments will be actively developed within `/src` and Native environments will be developed within `/app`.
37
-
* Warning: Choosing to develop for Native only will move the main entry point of the project and development folder to `/app`, copy necessary files and then delete `/src`.
36
+
* By default, the plugin will assume you want to develop for the Web and Native environments within the same project. As such, there will be two sides to the project where web environments will be actively developed within `/src` and Native environments will be developed within `/app` unless you choose to integrate `Nativescript-Vue-Web` and all files will be placed in `/src`.
37
+
* Warning: Choosing to develop for Native only will move the main entry point of the project and development folder to `/app`, it will copy the necessary files and then delete `/src`.
38
38
* By choosing `Dual`, you will be able to bring your own component framework into the web portion of the project. `NativeScript-Vue`[cannot use vue-router](https://nativescript-vue.org/en/docs/routing/vue-router/) currently, so you will have to provide your own manual routing. The templated options deployed with the plugin will show how to do basic manual routing.
39
39
5. Use [Nativescript-Vue-Web](https://github.com/Nativescript-Vue-Web/Nativescript-Vue-Web) to develop web components with `Nativescript-Vue` syntax? (Default: No)
40
40
* This prompt should only appear if you have chosen to develop in the Dual Web and Native environments.
41
-
* By chosing `Use Nativescript-Vue-Web component framework`, it will effecively integrate a web component framework that will allow you to develop components that can be used in the Web and Native side of the project. It uses `NativeScript-Vue` like syntax on components which will allow for the sharing of components between NativeScript and Web.
41
+
* By chosing `Yes. Use Nativescript-Vue-Web component framework`, it will effecively integrate a web component framework that will allow you to develop components that can be used in the Web and Native side of the project. It uses `NativeScript-Vue` like syntax on components which will allow for the sharing of components between NativeScript and Web.
42
42
6. What type of template do you want to start with? (Default: Simple)
43
43
* Simple is just a simple setup with a header and basic routing.
44
44
* Sidebar (currently disabled), will allow you to start with a project that includes a fixed header and pop-out sidebar menu.
@@ -55,8 +55,8 @@ You will have several options in serving and building the project:
55
55
56
56
The basic `serve` and `build` options should be similar to what is in a CLI 3 project except the added options to dictate which kind of environment you are using: `web`, `android` or `ios`. Please note that when building web projects, they will output to `dist` and when building native projects, they will output to `platforms\android` or `platforms\ios` depending on which you are building at the time.
57
57
58
-
#Webpack related information
59
-
The options passes in at `npm run` will dictate what webpack config is provided. The first choice webpack will make is if this is a `web` or `native` environment. Then, if it's a `native` environment, it will determine choices to be made between `ios` and `android`.
58
+
#### Webpack related information
59
+
The options passed in at `npm run` will dictate what webpack config is provided. The first choice webpack will make is if this is a `web` or `native` environment. Then, if it's a `native` environment, it will determine choices to be made between `ios` and `android`.
60
60
61
61
Each time the project is built or served, the plugin will copy the latest webpack config from the cli to the root of your project. When you build a project, it will clean-up this file at the end, but just serving the project will not. This is an issue with [nativescript-dev-webpack](https://github.com/NativeScript/nativescript-dev-webpack) and cannot be overcome at this time.
62
62
@@ -79,17 +79,16 @@ Prebuilt in the webpack config are several aliases that you can use. Here is a
79
79
80
80
81
81
## For TypeScript enabled projects
82
-
If your CLI 3 project has TypeScript enabled, then the plugin will attempt to give you a very basic TypeScript version of the template you choose. When you invoke the plugin and the template generator makes changes, you will notice the `*.d.ts` files that are usually in `src` will be moved to root so that they can be referenced inside of `src` and `app`. The plugin's webpack integration will ensure these files are referenced correctly at compile and runtimes.
82
+
If your CLI 3 project has TypeScript enabled, then the plugin will attempt to give you a very basic TypeScript version of the template you choose. When you invoke the plugin and the template generator makes changes, you will notice the `*.d.ts` files that are usually in `src` will be moved to `/types`. The plugin's webpack integration will ensure these files are referenced correctly at compile and runtimes.
83
+
84
+
There will also be additional `tsconfig.json` files added into the root that allow for specific configurations depending on the type of environment you are building for. You will see a `tsconfig.web.json` and a `tsconfig.native.json` file that extend the base `tsconfig.json` file in root. The plugin's webpack integration will ensure the correct `tsconfig` file is referenced at runtime.
83
85
84
86
## For Native environment development
85
-
It should be noted that the plugin will give you the ability to develop generic SFC's (\*.native.vue) to be used in Android and IOS, or if you need to differentiate between Android (\*.android.vue) and IOS (\*.ios.vue) then you can change the SFC's extension to map to the environment you choose.
87
+
It should be noted that the plugin will give you the ability to develop generic SFC's (\*.native.vue) to be used in both Android and IOS, or if you need to differentiate between Android (\*.android.vue) and IOS (\*.ios.vue) then you can change the SFC's extension to map to the environment you choose.
86
88
87
89
At `serve` or `build` in conjunction with the mode such as `android` or `ios`, it will filter which files are looked at. For instance, if you do `npm run serve:android`, then it will look for `*.native.vue` and `*.android.vue` files and ignore `*.ios.vue` files entirely. Conversely, it will do the same when your are doing the same for `ios` and will ignore `*.android.vue` files.
88
90
89
91
This will allow you to develop generic native components under the `*.native.vue` file extension, but in special cases, it may require you to do platform specific components. Use the corrosponding file extension to allow this to happen.
90
92
91
93
## Sharing components and assets between environments
92
94
If you want to use common components and assets between `web`, `android` and `ios`, you can do that. Based on directory structures and webpack aliases setup by the plugin, it is __highly__ suggested you place these common items in the `src` folder directory structure. For `assets`, place them in `src/assets` and for components, place them in `src/components`. At compile time, assets will be copied to the output directory's `assets` folder and can be universally accessed across environments via something like `~/assets/logo.png`. For components, they can be universally accessed via something similar to `components/HelloWorld`.
Copy file name to clipboardExpand all lines: generator/README.md
+20-11
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,27 @@
1
1
# nativescript-vue-cli-plugin - Generator Readme
2
2
3
-
It is __highlysuggested__ that you copy/paste the `simple` template in its entirety and then rename the copied directory. It will make it much easier for you to get starting using the existing logic in the generator. Modifications to the existing generator logic will be considered for PR, but __rarely approved__ as the changes could break all pre-existing templates.
3
+
It is __highly, highly, highly suggested__ that you copy/paste the `simple` template in its entirety and then rename the copied directory. It will make it much easier for you to get started using the existing logic in the generator. Modifications to the existing generator logic will be considered for PR, but will have to go through rigourous testing to ensure the changes do not break all pre-existing templates.
4
4
5
5
If you want to add additional templates to the plugin, then here's the information on how to do it:
6
6
7
7
1. Create a new option to the prompt question #6 concerning which template you'd like to deploy.
8
8
* The value for the template should be kept simple and easy.
9
9
2. Create a new directory under `/generator/templates`.
10
10
* The directory name should __exactly match__ the value from #1. For example if the value from #1 is `sidebar`, then the directory structure would be `/generator/templates/sidebar`
11
-
* Add a `globals.d.ts` file. This can be copied from the `simple` template directory
12
-
3. The new template directory must have a `src` and an `app` directory within it.
13
-
4. Inside the `src` directory, you should add the following in an effort to give the template feature consistancy to the other templates:
14
-
* tsconfig.json
11
+
3. The new template directory __must__ have a first-level subdirectory named `without-nvw`. 4. Within the `without-nvw` directory, it should have the following:
12
+
*`src` directory
13
+
*`app` directory
14
+
*`tsconfig.native.json` & `tsconfig.web.json` (so as to enable TypeScript support)
15
+
5. Inside the `without-nvw\src` directory, you should add the following in an effort to give the template feature consistancy to the other templates:
15
16
* router.js
16
17
* main.js
17
18
* App.vue
18
19
* views/About.vue (optional)
19
20
* views/Home.vue (optional)
20
21
* components/HelloWorld.vue (optional)
21
22
* assets/logo.png (optional, but highly encouraged to prove images are loading)
22
-
5. Inside the `app` directory, you should add the following in an effort to give the template feature consistancy to the other templates:
23
-
* tsconfig.json
24
-
* package.json
23
+
5. Inside the `without-nvw\app` directory, you should add the following in an effort to give the template feature consistancy to the other templates:
24
+
* package.json (as usual for Nativescript-Vue projects)
25
25
* main.js
26
26
* App.native.vue
27
27
* App.ios.vue
@@ -37,8 +37,17 @@ If you want to add additional templates to the plugin, then here's the informati
37
37
* components/HelloWorld.android.vue (optional)
38
38
* assets/logo.png (optional, but highly encouraged to prove images are loading)
39
39
40
-
Concerning the `tsconfig.json` files. These are necessary to ensure TypeScript enabled projects will work correctly. If your directory structure within your template is different than what is in the `simple` template, then you will need to adjust your `tsconfig.json` files to account for those differences. Again, it is __highly suggested__ that you don't deviate from the directory structure provided by the `simple` template.
40
+
If you want to include support for `Nativescript-Vue-Web` within your template, then you can also follow the pattern included in the `simple` template. You will need to:
41
+
1. Add a first-level subdirectory named `with-nvw`.
42
+
2. Within the `with-nvw` directory you will only need to add a `src` directory. You will __not__ need an `app` directory. Again, follow the `simple` template pattern.
43
+
3. Within `src`, you will essentially merge everything that is in the `without-nvw` side of the template. The one main difference is that the `main.js` file from the `app` directory will have to be named `main.native.js`.
41
44
42
-
Within the \*.vue files you will find [ejs](https://github.com/mde/ejs) syntax that will enable you to differentiate between TypeScript and non-TypeScript projects as well as projects that use Nativesript-Vue-Web and those that don't. Any new templates added to the project __must__ demonstrate they work across these options or the PR to add the template will be rejected. For the Native side of the template in the `app` directory, you won't have to wory about the Nativescript-Vue-Web option as that is only for the web side of the template in `src`. However, you will have to account for TypeScript/non-Typescript in `app` and `src` template files.
45
+
Concerning the two `tsconfig` files in the base of the template directory. These are necessary to ensure TypeScript enabled projects will work correctly. If your directory structure within your template is different than what is in the `simple` template, then you will need to adjust the two `tsconfig` files to account for those differences. Again, it is __highly encouraged__ that you don't deviate from the directory structure provided by the `simple` template.
46
+
47
+
If you add any of the optional files within the `app` directory structure, then you should make sure you have a \*.native.vue, \*.android.vue and \*.ios.vue example for each SFC. It would also be beneficial within each of those to have a way to identify to the developer which file is being used at compile time. Take a look at the `simple` template's `app\views\about.*.vue` examples to see a basic example of this.
48
+
49
+
Within the \*.vue files you will find [ejs](https://github.com/mde/ejs) syntax that will enable you to differentiate between TypeScript and non-TypeScript projects. Any new templates added to the project __must__ demonstrate they work across these options or the PR to add the template will be rejected.
50
+
51
+
### Word of warning concerning using EJS templates with Prettier
52
+
Prettier does not support EJS templates and if you have Prettier automatically fix all issues in a `*.vue` file, then you will run the risk of it overwriting sections of the template from one `if` statement to the `else` side of the statement. Pay close attention to this specifically in your `script` tags as it relates to the TypeScript vs. non-TypeScript parts of the template. Whichever one comes first in the `if` statement will overwrite the section after the `else` statement.
43
53
44
-
If you add any of the optional files within the `app` directory structure, then you should make sure you have a \*.native.vue, \*.android.vue and \*.ios.vue example for each SFC. It would also be beneficial within each of those to have a way to identify to the developer which file is being used at compile time. Take a look at the `simple` template's `app\views\about.*.vue` examples to see a basic example of this.
0 commit comments