Skip to content

Commit

Permalink
docs: update README (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chieffo2021 committed Mar 8, 2022
1 parent 3bf46f0 commit 7401c37
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,3 +372,34 @@ Options:
* ⚠️ O09:如果您遇到构建错误 `[rollup-plugin-dynamic-import-variables] Unexpected token`,则需要删除 `<img>` 标签中的空属性 `srcset``srcset=""`
* ⚠️ O10: Vite 无法解析一些静态资源,如`.PNG`,你可以把它放在 `assetsInclude` 选项中,比如 `assetsInclude: ['**.PNG']`
* ⚠️ O11:支持 `.md` markdown 文件作为 vue 组件,需要添加 [`vite-plugin-md`](https://github.com/antfu/vite-plugin-md) 插件
* ⚠️ O12: 该错误 `Uncaught ReferenceError: global is not defined`, 参阅[这里](https://github.com/vitejs/vite/issues/2618#issuecomment-820919951)
* > 作为参考,如果您只需要垫片 global,您可以将`<script>window.global = window;</script>`添加到您的`index.html`
* ⚠️ O13: 支持将SVG文件作为Vue组件加载
* ... 或遇到以下错误时
```
Uncaught (in promise) DOMException: Failed to execute 'createElement' on 'Document': The tag name provided ('/@fs/D:/project/example/node_modules/@example/example.svg') is not a valid name.
```
* 添加 [`vite-svg-loader`](https://github.com/jpkleemans/vite-svg-loader) 插件用于 **vue** 项目
* 添加 [`vite-plugin-svgr`](https://www.npmjs.com/package/vite-plugin-svgr) 插件用于 **react** 项目
* ⚠️ O14: 修复以下错误
```
[Vue warn]: Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".
```
* 您需要设置别名,如下所示
```javascript
resolve: {
alias: [
{ find: 'vue', replacement: 'vue/dist/vue.esm-bundler.js' }
]
}
```
* ⚠️ O15: 出于以下原因,您可能需要安装 [`vite-plugin-optimize-persist`](https://github.com/antfu/vite-plugin-optimize-persist) 插件
> Vite 的依赖预构建是很酷的,大大地提升了开发体验。虽然 Vite 可以智能地检测动态依赖关系,但它的按需检测行为有时会使复杂项目的启动相当缓慢。
```
[vite] new dependencies found: @material-ui/icons/Dehaze, @material-ui/core/Box, @material-ui/core/Checkbox, updating...
[vite] ✨ dependencies updated, reloading page...
[vite] new dependencies found: @material-ui/core/Dialog, @material-ui/core/DialogActions, updating...
[vite] ✨ dependencies updated, reloading page...
[vite] new dependencies found: @material-ui/core/Accordion, @material-ui/core/AccordionSummary, updating...
[vite] ✨ dependencies updated, reloading page...
```
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,34 @@ Legend of annotations:
* ⚠️ O09: if you encountered build error `[rollup-plugin-dynamic-import-variables] Unexpected token`, you need to remove empty attr `srcset` or `srcset=""` in `<img>` label.
* ⚠️ O10: Vite can't resolve some static asset, e.g. `.PNG`, you can put it in `assetsInclude` option like `assetsInclude: ['**.PNG']`
* ⚠️ O11: support `.md` markdown file as vue component, you need to add [`vite-plugin-md`](https://github.com/antfu/vite-plugin-md) plugin.
* ⚠️ O12: The error `Uncaught ReferenceError: global is not defined`, see also [here](https://github.com/vitejs/vite/issues/2618#issuecomment-820919951)
* > For reference, if you only need to shim global, you can add `<script>window.global = window;</script>` to your `index.html`
* ⚠️ O13: Support load SVG files as Vue components
* ... or when the following error is encountered
```
Uncaught (in promise) DOMException: Failed to execute 'createElement' on 'Document': The tag name provided ('/@fs/D:/project/example/node_modules/@example/example.svg') is not a valid name.
```
* add [`vite-svg-loader`](https://github.com/jpkleemans/vite-svg-loader) plugin for **vue** project
* add [`vite-plugin-svgr`](https://www.npmjs.com/package/vite-plugin-svgr) plugin for **react** project
* ⚠️ O14: Fix the following errors
```
[Vue warn]: Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".
```
* you need to set the alias as follows
```javascript
resolve: {
alias: [
{ find: 'vue', replacement: 'vue/dist/vue.esm-bundler.js' }
]
}
```
* ⚠️ O15: You may need to install the [`vite-plugin-optimize-persist`](https://github.com/antfu/vite-plugin-optimize-persist) plugin for the following reasons
> Vite's dependencies pre-optimization is cool and can improve the DX a lot. While Vite can smartly detect dynamic dependencies, it's on-demanded natural sometimes make the booting up for complex project quite slow.
```
[vite] new dependencies found: @material-ui/icons/Dehaze, @material-ui/core/Box, @material-ui/core/Checkbox, updating...
[vite] ✨ dependencies updated, reloading page...
[vite] new dependencies found: @material-ui/core/Dialog, @material-ui/core/DialogActions, updating...
[vite] ✨ dependencies updated, reloading page...
[vite] new dependencies found: @material-ui/core/Accordion, @material-ui/core/AccordionSummary, updating...
[vite] ✨ dependencies updated, reloading page...
```

0 comments on commit 7401c37

Please sign in to comment.