Vite 开发好用是好用,但是 build 做的太烂了吧

2021-05-26 15:32:08 +08:00
 wheelg

拿 vite 写了两个练手的小项目,开发过程无比丝滑,响应极快,很是舒服。但是一到 build 的时候就傻眼了,多入口的页面永远只打包第一个,配置文件不管路径写没写对都能成功打包( vite.config.js 是有输出的,但是 rollupOption 跟摆设一样),引入的第三方库打包后放到服务器上根本加载不出来,但是搜了打包后的代码明明是在里面的。。。只能说取代 webpack 道阻且长啊

3713 次点击
所在节点    程序员
11 条回复
theprimone
2021-05-26 15:53:54 +08:00
感觉还是使用上的问题吧,我用 Vite 搞了几个 SPA 项目了,当然也有一些坑,不过都过来了,最有代表性的是这个 https://github.com/theprimone/vite-react
jorneyr
2021-05-26 15:56:43 +08:00
@theprimone 楼主说的是多页,不是 SPA 。
66beta
2021-05-26 15:58:12 +08:00
webpack 的优势是插件多,生态成熟,它优化一下潜力更大
rioshikelong121
2021-05-26 16:00:03 +08:00
Vite is open-source software, you can contribute pull requests to Vite.
theprimone
2021-05-26 17:14:58 +08:00
@jorneyr 我的意思跟 4 楼一样,该提 issue 该 PR 搞起来才是真的。烂尾了还能吐槽一下,现在这个状态应该是怎么想着把 Vite 建设得更好。
weimo383
2021-05-26 17:16:02 +08:00
webpack 被你们抛弃了吗。。。
PinkRabbit
2021-05-26 17:17:22 +08:00
issue 提起来
jorneyr
2021-05-26 17:39:58 +08:00
@theprimone 也是,新东西毕竟和成熟的比起来有差距也是正常,提 issue 是个不错的建议。
flyslow
2021-05-26 22:29:37 +08:00
为啥不 vite 开发,webpack 打包
myCupOfTea
2021-05-27 09:27:53 +08:00
多入口没试过,但是你说的其他问题确实没遇到,而且我的依赖也不少
```json
{
"@ant-design/icons": "^4.6.2",
"@types/classnames": "^2.3.1",
"@types/lodash-es": "^4.17.4",
"@types/nprogress": "^0.2.0",
"@types/qs": "^6.9.6",
"@types/react-beautiful-dnd": "^13.0.0",
"@types/react-router-dom": "^5.1.7",
"ag-grid-community": "^25.2.1",
"ag-grid-react": "^25.2.0",
"antd": "^4.15.6",
"array-move": "^3.0.1",
"axios": "^0.21.1",
"classnames": "^2.3.1",
"dayjs": "^1.10.4",
"lodash-es": "^4.17.21",
"nprogress": "^0.2.0",
"qs": "^6.10.1",
"react": "^17.0.0",
"react-beautiful-dnd": "^13.1.0",
"react-dom": "^17.0.0",
"react-helmet-async": "^1.0.9",
"react-router-dom": "^5.2.0",
"react-use": "^17.2.4",
"swr": "^0.5.6"
}

```
lathlaeril
2021-06-03 22:17:17 +08:00
https://vitejs.dev/guide/build.html#multi-page-app

需要在`vite.config.js`中指定`build.rollupOptions.input

Dev Server 不指定也能预览。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/779342

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX