docs: document new features

This commit is contained in:
Evan You
2018-06-13 14:48:06 -04:00
parent 5792ed89fb
commit fe936f3dfa
3 changed files with 36 additions and 7 deletions
+19 -1
View File
@@ -42,7 +42,25 @@ See [@babel-preset/env docs](https://new.babeljs.io/docs/en/next/babel-preset-en
## Modern Mode
> TODO
With Babel we are able to leverage all the newest language features in ES2015+, but that also means we have to ship transpiled and polyfilled bundles in order to support older browsers. These transpiled bundles often more verbose than the original native ES2015+ code, and also parses and runs slower. Given that today a good majority of the modern browsers have decent support for native ES2015, it is a waste that we have to ship heavier and less efficient code to those browsers just because we have to support older ones.
Vue CLI offers a "Modern Mode" to help you solve this problem. When building for production with the following command:
``` bash
vue-cli-service build --modern
```
Vue CLI will produce two versions of your app: one modern bundle targeting modern browsers that support [ES modules](https://jakearchibald.com/2017/es-modules-in-browsers/), and one legacy bundle targeting older browsers that do not.
The cool part though is that there are no special deployment requirements. The generated HTML file automatically employs the techniques discussed in [Phillip Walton's excellent post](https://philipwalton.com/articles/deploying-es2015-code-in-production-today/):
- The modern bundle is loaded with `<script type="module">`, in browsers that support it; they are also preloaded using `<link rel="modulepreload">` instead.
- The legacy bundle is loaded with `<script nomodule>`, which is ignored by browsers that support ES modules.
- A fix for `<script nomodule>` in Safari 10 is also automatically injected.
For a Hello World app, the modern bundle is already 16% smaller. In production, the modern bundle will typically result in significantly faster parsing and evaluation, improving your app's loading performance.
[autoprefixer]: https://github.com/postcss/autoprefixer
[babel-preset-env]: https://new.babeljs.io/docs/en/next/babel-preset-env.html
+16 -6
View File
@@ -55,16 +55,26 @@ Usage: vue-cli-service build [options] [entry|pattern]
Options:
--mode specify env mode (default: production)
--dest specify output directory (default: dist)
--target app | lib | wc | wc-async (default: app)
--name name for lib or web-component mode (default: "name" in package.json or entry filename)
--watch watch for changes
--mode specify env mode (default: production)
--dest specify output directory (default: dist)
--modern build app targeting modern browsers with auto fallback
--target app | lib | wc | wc-async (default: app)
--name name for lib or web-component mode (default: "name" in package.json or entry filename)
--no-clean do not remove the dist directory before building the project
--report generate report.html to help analyze bundle content
--report-json generate report.json to help analyze bundle content
--watch watch for changes
```
`vue-cli-service build` produces a production-ready bundle in the `dist/` directory, with minification for JS/CSS/HTML and auto vendor chunk splitting for better caching. The chunk manifest is inlined into the HTML.
It is also possible to build any component(s) inside your project as a library or as web components. See [Build Targets](./build-targets.md) for more details.
There are a few useful flags:
- `--modern` builds your app using [Modern Mode](./browser-compatibility.md#modern-mode), shipping native ES2015 code to modern browsers that support it, with auto fallback to a legacy bundle.
- `--target` allows you to build any component(s) inside your project as a library or as web components. See [Build Targets](./build-targets.md) for more details.
- `--report` and `--report-json` will generate reports based on your build stats that can help you analyze the size of the modules included in your bundle.
## vue-cli-service inspect
@@ -17,6 +17,7 @@ module.exports = (api, options) => {
usage: 'vue-cli-service serve [options] [entry]',
options: {
'--open': `open browser on server start`,
'--copy': `copy url to clipboard on server start`,
'--mode': `specify env mode (default: development)`,
'--host': `specify host (default: ${defaults.host})`,
'--port': `specify port (default: ${defaults.port})`,