-
Notifications
You must be signed in to change notification settings - Fork 13
correct grammar, move prod usage #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
243e095
c446498
cabaa28
abab893
57fc2e2
824f415
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
|
|
||
| **:rocket: Add an API in your Vue application in 2 minutes!** | ||
|
|
||
| This is a vue-cli 3.x plugin to add an Node Express server in your Vue project. | ||
| This is a vue-cli 3.x plugin to add a Node Express server to your Vue project. | ||
|
|
||
| <br> | ||
|
|
||
|
|
@@ -15,11 +15,11 @@ This is a vue-cli 3.x plugin to add an Node Express server in your Vue project. | |
|
|
||
| **:star: Features:** | ||
|
|
||
| - Included fully customizable Express Server: | ||
| - Just add your api routes into your project (with import/export support) without thinking to something else. | ||
| - Optional automatic fallback to the Vue app, to serve both the api and the application with only one command. | ||
| - Optional socket.io support. | ||
| - (soon) Included optional example routes and components. | ||
| - Fully customizable Express Server: | ||
| - Just add your api routes into your project (with import/export support) | ||
| - Optional automatic fallback to the Vue app. Serve both the api and the application with Express | ||
| - Optional socket.io support | ||
| - :soon: Example routes and components | ||
|
|
||
| ## Table of contents | ||
|
|
||
|
|
@@ -35,46 +35,53 @@ This is a vue-cli 3.x plugin to add an Node Express server in your Vue project. | |
|
|
||
| :warning: Make sure you have vue-cli 3.x.x: | ||
|
|
||
| ``` | ||
| ```sh | ||
| vue --version | ||
| ``` | ||
|
|
||
| If you don't have a project created with vue-cli 3.x yet: | ||
| If you have not installed vue-cli 3, first follow the install instructions here: [https://cli.vuejs.org/](https://cli.vuejs.org/) | ||
|
|
||
| ``` | ||
| Generate a project using vue-cli 3 | ||
|
|
||
| ```sh | ||
| vue create my-new-app | ||
| ``` | ||
|
|
||
| Navigate to the newly created project folder and add the cli plugin: | ||
| Navigate to the newly created project folder and add this plugin. It is good practice to commit your changes prior to installing a new plugin. | ||
|
|
||
| ``` | ||
| ```sh | ||
| cd my-new-app | ||
| vue add express | ||
| ``` | ||
| Soon: | ||
| *:information_source: An example `APIExample.vue` component will be added into your sources if you chose to include the examples.* | ||
|
|
||
| :soon: _:information_source: An example `APIExample.vue` component will be added should you choose to include examples when installing the plugin._ | ||
anguspalmer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Usage | ||
|
|
||
| To start your server for development purpose, use this commands: | ||
| To start your server for development, run: | ||
|
|
||
| ``` | ||
| ```sh | ||
| yarn express | ||
| ``` | ||
|
|
||
| The server will be automatically restarted when a change is detected. | ||
| The server will watch for file changes and automatically restart. | ||
|
|
||
| You just then have to start the app: | ||
| Then you just have to start the web app: | ||
|
|
||
| ``` | ||
| ```sh | ||
| yarn serve | ||
| ``` | ||
|
|
||
| To run the server only once for production use, run: | ||
| ``` | ||
| yarn express:run | ||
| Alternatively you can serve the web app and api together from express by setting the plugin option, `shouldServeApp` to `true`. See the [Configuration](#configuration) section below for further details. You will also need to tell Express where to serve your web application by adding the following to `./srv/index.js`; | ||
|
|
||
| ```js | ||
| var router = express.Router(); | ||
| router.use(express.static("./dist")); | ||
| app.use("/", router); | ||
|
||
| ``` | ||
|
|
||
| Where `./dist` is the location of your built web application. | ||
|
|
||
| **Updating `vue-cli-plugin-express` will update the Express server service :+1:** | ||
|
|
||
| ## Injected Commands | ||
|
|
@@ -105,21 +112,22 @@ module.exports = { | |
| } | ||
| ``` | ||
|
|
||
| ## Use your app in production | ||
| ### Production | ||
anguspalmer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Move `@vue/cli-service` from `devDependencies`to `dependencies`. | ||
| For production use you need to move `@vue/cli-service` from `devDependencies`to `dependencies`. | ||
| Then build your app and run the server; | ||
anguspalmer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Execute the following commands: | ||
| ```bash | ||
| ```sh | ||
| yarn build | ||
| yarn express:run | ||
| ``` | ||
|
|
||
| For most of cloud hosting services, you can add a `start` command that will be triggered automatically: | ||
| Most cloud hosting services will expect a npm `start` script to run your application. It is recommended you add the following to your `package.json`: | ||
|
|
||
| ```json | ||
| { | ||
| "scripts": { | ||
| "start": "yarn express:run" | ||
| "start": "yarn express:run" | ||
| } | ||
| } | ||
| ``` | ||
Uh oh!
There was an error while loading. Please reload this page.