V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
wheelg
V2EX  ›  程序员

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

  •  
  •   wheelg · 2021-05-26 15:32:08 +08:00 · 3694 次点击
    这是一个创建于 1068 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    11 条回复    2021-06-03 22:17:17 +08:00
    theprimone
        1
    theprimone  
       2021-05-26 15:53:54 +08:00
    感觉还是使用上的问题吧,我用 Vite 搞了几个 SPA 项目了,当然也有一些坑,不过都过来了,最有代表性的是这个 https://github.com/theprimone/vite-react
    jorneyr
        2
    jorneyr  
       2021-05-26 15:56:43 +08:00   ❤️ 1
    @theprimone 楼主说的是多页,不是 SPA 。
    66beta
        3
    66beta  
       2021-05-26 15:58:12 +08:00
    webpack 的优势是插件多,生态成熟,它优化一下潜力更大
    rioshikelong121
        4
    rioshikelong121  
       2021-05-26 16:00:03 +08:00
    Vite is open-source software, you can contribute pull requests to Vite.
    theprimone
        5
    theprimone  
       2021-05-26 17:14:58 +08:00
    @jorneyr 我的意思跟 4 楼一样,该提 issue 该 PR 搞起来才是真的。烂尾了还能吐槽一下,现在这个状态应该是怎么想着把 Vite 建设得更好。
    weimo383
        6
    weimo383  
       2021-05-26 17:16:02 +08:00 via Android
    webpack 被你们抛弃了吗。。。
    PinkRabbit
        7
    PinkRabbit  
       2021-05-26 17:17:22 +08:00
    issue 提起来
    jorneyr
        8
    jorneyr  
       2021-05-26 17:39:58 +08:00
    @theprimone 也是,新东西毕竟和成熟的比起来有差距也是正常,提 issue 是个不错的建议。
    flyslow
        9
    flyslow  
       2021-05-26 22:29:37 +08:00 via iPhone
    为啥不 vite 开发,webpack 打包
    myCupOfTea
        10
    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
        11
    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 不指定也能预览。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1280 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 17:46 · PVG 01:46 · LAX 10:46 · JFK 13:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.