Skip to content

Commit 663235b

Browse files
committed
production deployment
1 parent 6ef6289 commit 663235b

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed
Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,53 @@
1-
# Production Deployment <Badge text="WIP" />
1+
# Production Deployment
22

33
## Development vs. Production
44

5+
During development, Vue provides a number of features to improve the development experience:
6+
7+
- Warning for common errors and pitfalls
8+
- Props / events validation
9+
- Reactivity debugging hooks
10+
- Devtools integration
11+
12+
However, these features become useless in production. Some of the warning checks also introduce small runtime overhead. When deploying to production, we should drop all the unused, development-only code branches for smaller payload size and better performance.
13+
514
## Without Build Tools
615

16+
If you are using Vue without a build tool by loading it from a CDN or self-hosted script, make sure to use the production build (dist files that end in `.prod.js`) when deploying to production. Production builds are pre-minified with all development-only code branches removed.
17+
18+
- If using global build (accessing via the `Vue` global): use `vue.global.prod.js`.
19+
- If using ESM build (accessing via native ESM imports): use `vue.esm-browser.prod.js`.
20+
21+
Consult the [dist file guide](https://github.com/vuejs/vue-next/tree/master/packages/vue#which-dist-file-to-use) for more details.
22+
723
## With Build Tools
824

25+
Projects scaffolded via `create-vue` (based on Vite) or Vue CLI (based on webpack) are pre-configured for production builds.
26+
27+
If using a custom setup, make sure that:
28+
29+
1. `vue` resolves to `vue.runtime.esm-bundler.js`.
30+
2. The [compile time feature flags](https://github.com/vuejs/vue-next/tree/master/packages/vue#bundler-build-feature-flags) are properly configured.
31+
3. <code>process.env<wbr>.NODE_ENV</code> is replaced with `"production"` during build.
32+
33+
Additional references:
34+
35+
- [Vite production build guide](https://vitejs.dev/guide/build.html)
36+
- [Vite deployment guide](https://vitejs.dev/guide/static-deploy.html)
37+
- [Vue CLI deployment guide](https://cli.vuejs.org/guide/deployment.html)
38+
939
## Tracking Runtime Errors
40+
41+
The [app-level error handler](/api/application.html#app-config-errorhandler) can be used to report errors to tracking services:
42+
43+
```js
44+
import { createApp } from 'vue'
45+
46+
const app = createApp(...)
47+
48+
app.config.errorHandler = (err, instance, info) => {
49+
// report error to tracking services
50+
}
51+
```
52+
53+
Services such as [Sentry](https://docs.sentry.io/platforms/javascript/guides/vue/) and [Bugsnag](https://docs.bugsnag.com/platforms/javascript/vue/) also provide official integrations for Vue.

0 commit comments

Comments
 (0)