Skip to content

Commit 19ab985

Browse files
feat: update Vue Generator doc (#1634)
1 parent 356a99d commit 19ab985

File tree

1 file changed

+56
-45
lines changed

1 file changed

+56
-45
lines changed

create-client/vuejs.md

Lines changed: 56 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
# Vue.js Generator
22

3-
Bootstrap a Vue.js application using create-vue:
3+
Bootstrap a Vue 3 application using create-vue:
44

55
```console
6-
npm init vue@2 -- --router my-app
6+
npm init vue@latest -- --typescript --router --pinia --eslint-with-prettier my-app
77
cd my-app
88
```
99

1010
Install the required dependencies:
1111

1212
```console
13-
npm install vuex@3 vuex-map-fields lodash
14-
```
15-
16-
Optionally, install Bootstrap and Font Awesome to get an app that looks good:
17-
18-
```console
19-
npm install add bootstrap font-awesome
13+
npm install dayjs lodash @types/lodash
2014
```
2115

2216
To generate all the code you need for a given resource run the following command:
@@ -26,46 +20,63 @@ npm init @api-platform/client https://demo.api-platform.com src/ -- --generator
2620
```
2721

2822
Replace the URL with the entrypoint of your Hydra-enabled API.
29-
You can also use an OpenAPI documentation with `-f openapi3`.
23+
You can also use an OpenAPI documentation with `https://demo.api-platform.com/docs.json` and `-f openapi3`.
3024

3125
Omit the resource flag to generate files for all resource types exposed by the API.
3226

33-
The code is ready to be executed! Register the generated routes and store modules. Here is an example:
34-
35-
```javascript
36-
// main.js
37-
import Vue from 'vue'
38-
import Vuex from 'vuex';
39-
import VueRouter from 'vue-router';
40-
import App from './App.vue';
41-
import 'bootstrap/dist/css/bootstrap.css';
42-
import 'font-awesome/css/font-awesome.css';
43-
import book from './store/modules/book/';
44-
import bookRoutes from './router/book';
45-
46-
Vue.config.productionTip = false;
47-
48-
Vue.use(Vuex);
49-
Vue.use(VueRouter);
50-
51-
const store = new Vuex.Store({
52-
modules: {
53-
book,
54-
}
55-
});
56-
57-
const router = new VueRouter({
58-
mode: 'history',
59-
routes: [
60-
...bookRoutes,
27+
**Note:** Make sure to follow the result indications of the command to register the routes.
28+
29+
Replace the content of `App.vue` with the following code:
30+
31+
```html
32+
// src/App.vue
33+
<template>
34+
<RouterView />
35+
</template>
36+
37+
<script setup lang="ts">
38+
import { RouterView } from "vue-router";
39+
</script>
40+
```
41+
42+
Optionally, install Tailwind to get an app that looks good:
43+
44+
```console
45+
npm install -D tailwindcss postcss autoprefixer
46+
npx tailwindcss init -p
47+
```
48+
49+
Replace the content of `tailwind.config.js` by:
50+
51+
```js
52+
// tailwind.config.js
53+
/** @type {import('tailwindcss').Config} */
54+
module.exports = {
55+
content: [
56+
"./index.html",
57+
"./src/**/*.{vue,js,ts,jsx,tsx}",
6158
],
62-
});
59+
theme: {
60+
extend: {},
61+
},
62+
plugins: [],
63+
};
64+
```
65+
66+
Replace the content of `src/assets/main.css` by:
6367

64-
new Vue({
65-
store,
66-
router,
67-
render: h => h(App),
68-
}).$mount('#app');
68+
```css
69+
@tailwind base;
70+
@tailwind components;
71+
@tailwind utilities;
6972
```
7073

71-
Go to `https://localhost/books/` to start using your app.
74+
You can launch the server with:
75+
76+
```console
77+
npm run dev
78+
```
79+
80+
Go to `http://localhost:5173/books/` to start using your app.
81+
82+
**Note:** In order to Mercure to work, you have to use the port 3000.

0 commit comments

Comments
 (0)