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

Vite+React+TS+Eslint+Prettier starter kit

  •  
  •   XTTX · 2021-11-13 15:47:39 +08:00 · 2805 次点击
    这是一个创建于 1101 天前的主题,其中的信息可能已经有所发展或是发生改变。
    Vite 用 es-build, 速度就不用多讲了。对比 CRA, 好多地方有不同。 我花了不少时间,搜了不少东西,做了一个自己用的 starter kit.

    Vite + React + Typescript + Eslint + Airbnb eslint rules + Airbnb Typescript rules + Prettier + env variable import + Absolute Import Path


    https://github.com/jt6677/vite_ts_eslint_prettier_aribnbts

    ==============================================
    !yes, tons of setup and config files.

    ==============================================
    env variable import:

    You need to add type in env.d.ts like "readonly VITE_ANYTHING: string"
    variables MUST start with VITE_
    usage of env variable in your app, no need to import, just use it as a global variable: console.log(import.meta.env.VITE_API_URL)

    ==============================================
    Absolute Import Path

    import App from "~/components". ~/ is the absoulte path, equal to ./src

    ==============================================
    reverse Proxy in vite.config.ts
    XTTX
        1
    XTTX  
    OP
       2021-11-13 15:48:28 +08:00
    Vite + React + Typescript + Eslint + Airbnb eslint rules + Airbnb Typescript rules + Prettier + env variable import + Absolute Import Path

    !yes, tons of setup and config files.

    ==============================================
    env variable import:

    You need to add type in env.d.ts like "readonly VITE_ANYTHING: string"
    variables MUST start with VITE_
    usage of env variable in your app, no need to import, just use it as a global variable: console.log(import.meta.env.VITE_API_URL)

    ==============================================
    Absolute Import Path

    import App from "~/components". ~/ is the absoulte path, equal to ./src

    ==============================================
    reverse Proxy in vite.config.ts
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3742 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 10:40 · PVG 18:40 · LAX 02:40 · JFK 05:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.