chore: merge branch 'master' into dev

This commit is contained in:
Haoqun Jiang
2019-11-27 00:03:10 +08:00
7 changed files with 26 additions and 10 deletions
+5 -1
View File
@@ -50,6 +50,10 @@ A lib build outputs:
- `dist/myLib.css`: Extracted CSS file (can be forced into inlined by setting `css: { extract: false }` in `vue.config.js`)
::: warning
If you are developing a library or in a monorepo, please be aware that CSS imports **are side effects**. Make sure to **remove** `"sideEffects": false` in the `package.json`, otherwise CSS chunks will be dropped by webpack in production builds.
:::
### Vue vs. JS/TS Entry Files
When using a `.vue` file as entry, your library will directly expose the Vue component itself, because the component is always the default export.
@@ -148,7 +152,7 @@ Now on the page, the user only needs to include Vue and the entry file:
When building a [Webcomponent](#web-component) or [Library](#library), the entry point is not `main.js`, but an `entry-wc.js` file, generated here: [https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/commands/build/resolveWcEntry.js](https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/commands/build/resolveWcEntry.js)
So to use vuex in web component target, you need to initialize the store in `App.vue`:
So to use vuex in web component target, you need to initialize the store in `App.vue`:
``` js
import store from './store'
+7 -1
View File
@@ -63,7 +63,7 @@ The `vue-cli-service serve` command starts a dev server (based on [webpack-dev-s
In addition to the command line flags, you can also configure the dev server using the [devServer](../config/#devserver) field in `vue.config.js`.
`[entry]` in the CLI command is defined as *the entry file*, not *an additional entry file*. If you overwrite the entry in the CLI, then the entries from `config.pages` are no longer considered, which may cause an error.
`[entry]` in the CLI command is defined as *the entry file*, not *an additional entry file*. If you overwrite the entry in the CLI, then the entries from `config.pages` are no longer considered, which may cause an error. Defaults to [entryFile](../dev-guide/generator-api.html#entryfile).
## vue-cli-service build
@@ -167,6 +167,12 @@ When installed, `@vue/cli-service` also installs [yorkie](https://github.com/yyx
{
"gitHooks": {
"pre-commit": "lint-staged"
},
"lint-staged": {
"*.{js,vue}": [
"vue-cli-service lint",
"git add"
]
}
}
```
+3 -3
View File
@@ -112,9 +112,9 @@ module.exports = {
// For Vue CLI v3 users, please refer to css-loader v1 documentations
// https://github.com/webpack-contrib/css-loader/tree/v1.0.1
modules: {
localIdentName: '[name]-[hash]',
localsConvention: 'camelCaseOnly'
}
localIdentName: '[name]-[hash]'
},
localsConvention: 'camelCaseOnly'
}
}
}
+5 -3
View File
@@ -130,6 +130,8 @@ pages: # the job must be named pages
- npm run build
- mv public public-vue # GitLab Pages hooks on the public folder
- mv dist public # rename the dist folder (result of npm run build)
# optionally, you can activate gzip support wih the following line:
- find public -type f -regex '.*\.\(htm\|html\|txt\|text\|js\|css\)$' -exec gzip -f -k {} \;
artifacts:
paths:
- public # artifact path must be /public for GitLab Pages to pick it up
@@ -137,15 +139,15 @@ pages: # the job must be named pages
- master
```
Typically, your static website will be hosted on https://yourUserName.gitlab.io/yourProjectName, so you will also want to create an initial `vue.config.js` file to [update the `BASE_URL`](https://github.com/vuejs/vue-cli/tree/dev/docs/config#baseurl) value to match:
Typically, your static website will be hosted on https://yourUserName.gitlab.io/yourProjectName, so you will also want to create an initial `vue.config.js` file to [update the `BASE_URL`](https://github.com/vuejs/vue-cli/tree/dev/docs/config#baseurl) value to match your project name (the [`CI_PROJECT_NAME` environment variable](https://docs.gitlab.com/ee/ci/variables/predefined_variables.html) contains this value):
```javascript
// vue.config.js file to be place in the root of your repository
// make sure you update `yourProjectName` with the name of your GitLab project
module.exports = {
publicPath: process.env.NODE_ENV === 'production'
? '/yourProjectName/'
? '/' + process.env.CI_PROJECT_NAME + '/'
: '/'
}
```
+1 -1
View File
@@ -224,7 +224,7 @@ It now requires `eslint`, `eslint-plugin-prettier` and `prettier` as peer depend
For older projects, if you encountered issues like `Cannot find module: eslint-plugin-prettier`, please run the following command to fix it:
```sh
npm install --sav-dev eslint@5 @vue/eslint-config-prettier@5 eslint-plugin-prettier prettier
npm install --save-dev eslint@5 @vue/eslint-config-prettier@5 eslint-plugin-prettier prettier
```
------
+1 -1
View File
@@ -16,7 +16,7 @@
如果有依赖需要 polyfill,你有几种选择:
1. **如果该依赖基于一个目标环境不支持的 ES 版本撰写:** 将其添加到 `vue.config.js` 中的 [`transpileDependencies`](../config/#transpiledependencies) 选项。这会为该依赖同时开启语法语法转换和根据使用情况检测 polyfill。
1. **如果该依赖基于一个目标环境不支持的 ES 版本撰写:** 将其添加到 `vue.config.js` 中的 [`transpileDependencies`](../config/#transpiledependencies) 选项。这会为该依赖同时开启语法转换和根据使用情况检测 polyfill。
2. **如果该依赖交付了 ES5 代码并显式地列出了需要的 polyfill:** 你可以使用 `@vue/babel-preset-app` 的 [polyfills](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/babel-preset-app#polyfills) 选项预包含所需要的 polyfill。**注意 `es6.promise` 将被默认包含,因为现在的库依赖 Promise 是非常普遍的。**
+4
View File
@@ -54,6 +54,10 @@ dist/myLib.css 0.33 kb 0.23 kb
- `dist/myLib.css`:提取出来的 CSS 文件 (可以通过在 `vue.config.js` 中设置 `css: { extract: false }` 强制内联)
::: warning 警告
如果你在开发一个库或多项目仓库 (monorepo),请注意导入 CSS **是具有副作用的**。请确保在 `package.json` 中**移除** `"sideEffects": false`,否则 CSS 代码块会在生产环境构建时被 webpack 丢掉。
:::
### Vue vs. JS/TS 入口文件
当使用一个 `.vue` 文件作为入口时,你的库会直接暴露这个 Vue 组件本身,因为组件始终是默认导出的内容。