{"id":7086,"date":"2022-12-13T17:45:54","date_gmt":"2022-12-13T16:45:54","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=7086"},"modified":"2025-11-12T11:56:46","modified_gmt":"2025-11-12T10:56:46","slug":"react-fast-developing-with-vite","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/react-fast-developing-with-vite\/","title":{"rendered":"React: fast developing with Vite"},"content":{"rendered":"\n<p><a href=\"https:\/\/vitejs.dev\">https:\/\/vitejs.dev<\/a><\/p>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"sh\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\"># this command does not work?!\n#npm create vite@latest my-app -- --template react-ts\n\n# but this one does:\nnpx create-vite  my-app -- --template react-ts\n\n# or:\nmkdir my-app\ncd my-app\ngit init\nnpx create-vite . -- --template react-ts\nnpm i --save-dev vite-plugin-checker\n# or add to package.json command\n#\"start\": \"concurrently --kill-others \\\"tsc --noEmit --watch\\\" \\\"vite\\\"\",\n\n<\/pre><\/div>\n\n\n\n<p><a href=\"https:\/\/vite.dev\/guide\/features.html#transpile-only\">https:\/\/vite.dev\/guide\/features.html#transpile-only<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/fi3ework\/vite-plugin-checker\">https:\/\/github.com\/fi3ework\/vite-plugin-checker<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Vite Hot Reload Persist (HMR)<\/h2>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"typescript\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\">\/\/ helper function: hotReloadPersist or createPersistentSingleton\nexport function hotReloadPersist&lt;T>(\n    key: string,\n    factory: () => T,\n    hot?: ImportMeta['hot']\n): T {\n    \/\/ eslint-disable-next-line @typescript-eslint\/no-explicit-any\n    const data = hot?.data as Record&lt;string, any> | undefined;\n    if (data) {\n        if (!data[key]) data[key] = factory();\n        return data[key];\n    }\n    return factory();\n}\n\n\/\/ reuse same class when hot reloading module\nexport const domainPorts = hotReloadPersist(\"domainPorts\", () => new DomainPorts(), import.meta.hot);\n<\/pre><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/vitejs.dev https:\/\/vite.dev\/guide\/features.html#transpile-only https:\/\/github.com\/fi3ework\/vite-plugin-checker Vite Hot Reload Persist (HMR)<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7086","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/7086","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=7086"}],"version-history":[{"count":13,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/7086\/revisions"}],"predecessor-version":[{"id":9906,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/7086\/revisions\/9906"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=7086"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=7086"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=7086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}