Skip to content

Commit

Permalink
fix(vue-next): fix js release bundle size too big issue
Browse files Browse the repository at this point in the history
  • Loading branch information
gguoyu committed Mar 18, 2024
1 parent e2e79ac commit 37925ef
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/api/hippy-vue/vue3.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,19 @@ webpack-plugin.ts 封装了 SSR 渲染所需 Hippy App 的初始化逻辑
因 SSR 的渲染方式和生命周期等与客户端渲染方式有一些差异,因此需要在代码编写过程中注意,这里可以参考[Vue官方的SSR指引](https://cn.vuejs.org/guide/scaling-up/ssr.html#writing-ssr-friendly-code)
- Vue 构建结果体积问题
因为 @hippy/vue-next 项目使用的是已编译的 Vue 组件,所以并不依赖于 Vue 的编译器,而默认的 webpack 打包会使用完整版本的 Vue 进行构建,会将不需要的编译器也打包在构建产物中,因此需要指定使用运行时版本的 Vue 产物
```javascript
// scripts/hippy-webpack.android.js
const aliases = {
// ...other options
// hippy 仅需要运行时的 Vue,在这里指定
vue$: 'vue/dist/vue.runtime.esm-bundler.js',
};
```
# 示例
更多使用请参考 [示例项目](https://github.com/Tencent/Hippy/tree/main/examples/hippy-vue-next-demo).
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ module.exports = {
alias: (() => {
const aliases = {
src: path.resolve('./src'),
// hippy 仅需要运行时的 Vue,在这里指定
vue$: 'vue/dist/vue.runtime.esm-bundler.js',
};

// If @vue/runtime-core was built exist in packages directory then make an alias
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ module.exports = {
alias: (() => {
const aliases = {
src: path.resolve('./src'),
// hippy 仅需要运行时的 Vue,在这里指定
vue$: 'vue/dist/vue.runtime.esm-bundler.js',
};

// If @vue/runtime-core was built exist in packages directory then make an alias
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ module.exports = {
alias: (() => {
const aliases = {
src: path.resolve('./src'),
// hippy 仅需要运行时的 Vue,在这里指定
vue$: 'vue/dist/vue.runtime.esm-bundler.js',
};

// If @vue/runtime-core was built exist in packages directory then make an alias
Expand Down

0 comments on commit 37925ef

Please sign in to comment.