fgt1t5y

原生开发 TS 如何编译成 JS 并自动处理引入路径

  •  
  •   fgt1t5y · Apr 14, 2024 · 2011 views
    This topic created in 778 days ago, the information mentioned may be changed or developed.

    我想要 TypeScript + Lit ( Web Component 框架) 开发一个纯静态的博客项目,目录结构如下:

    我想要的是工作区所有 TS 、CSS 文件编译并打包,并处理所有 html 文件的 assets ( JS 等资源)的引入。我试过用 Vite ,但是它只能构建 SPA 。

    又大佬做过类似的方案吗?或是又更好的方案?

    7 replies    2024-04-21 02:29:59 +08:00
    orzorzorzorz
        1
    orzorzorzorz  
       Apr 14, 2024
    试试插件丰富的 webpack ?
    fgt1t5y
        2
    fgt1t5y  
    OP
       Apr 14, 2024
    @orzorzorzorz #1 好 我去琢磨一下
    LandCruiser
        3
    LandCruiser  
       Apr 14, 2024
    https://lit.dev/docs/tools/production/
    这个肯定要自己会 webpack 和 rollup 的简单配置,不会的话需要学一下。
    fgt1t5y
        4
    fgt1t5y  
    OP
       Apr 15, 2024
    @LandCruiser 有空看看
    linkopeneyes
        5
    linkopeneyes  
       Apr 18, 2024
    我记得 vite 的入口可以指定很多个的,只要入口的 html 引入的 ts,css 都会被 vite 编译的吧
    fgt1t5y
        6
    fgt1t5y  
    OP
       Apr 18, 2024
    @sjhhjx0122 好主意 我可以写个插件遍历所有 HTML 文件设为入口
    WizardMeow
        7
    WizardMeow  
       Apr 21, 2024
    你搜搜 SSG 这个概念
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   937 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 21:26 · PVG 05:26 · LAX 14:26 · JFK 17:26
    ♥ Do have faith in what you're doing.