diff --git a/README.md b/README.md index 8cd5876..98d37e8 100644 --- a/README.md +++ b/README.md @@ -178,3 +178,26 @@ The github action is included in this sample, you can use it to publish your new prerelease: true # change this to false ``` + +## How to remove svelte dependencies + +This plugin is packaged in vite and provides a dependency on the svelte framework. However, in practice some developers may not want to use svelte and only want to use the vite package. + +In fact you can use this template without using svelte without any modifications at all. The compilation-related parts of the svelte compilation are loaded into the vite workflow as plugins, so even if you don't have svelte in your project, it won't matter much. + +If you insist on removing all svelte dependencies so that they do not pollute your workspace, you can perform the following steps. 1. + +1. delete the + ```json + { + "@sveltejs/vite-plugin-svelte": "^2.0.3", + "@tsconfig/svelte": "^4.0.1", + "svelte": "^3.57.0" + } + ``` +2. delete the `svelte.config.js` file +3. delete the following line from the `vite.config.js` file + - Line 6: `import { svelte } from "@sveltejs/vite-plugin-svelte"` + - Line 20: `svelte(),` +4. delete line 37 of `tsconfig.json` from `"svelte"` 5. +5. re-run `pnpm i` diff --git a/README_zh_CN.md b/README_zh_CN.md index 5e40813..45a9fd7 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -167,4 +167,25 @@ PR 社区集市仓库。 prerelease: true # 把这个改为 false ``` +## 如何去掉 svelte 依赖 +本插件使用 vite 打包,并提供了 svelte 框架依赖。不过实际情况下可能有些开发者并不想要 svelte,只希望使用 vite 打包。 + +实际上你可以完全不做任何修改,就可以在不使用 svelte 的前提下使用这个模板。与 svelte 编译的编译相关的部分是以插件的形式载入到 vite 的工作流中,所以即使你的项目里面没有 svelte,也不会有太大的影响。 + +如果你执意希望删除掉所有 svelte 依赖以免它们污染你的工作空间,可以执行一下步骤: + +1. 删掉 package.json 中的 + ```json + { + "@sveltejs/vite-plugin-svelte": "^2.0.3", + "@tsconfig/svelte": "^4.0.1", + "svelte": "^3.57.0" + } + ``` +2. 删掉 `svelte.config.js` 文件 +3. 删掉 `vite.config.js` 文件中的 + - 第六行: `import { svelte } from "@sveltejs/vite-plugin-svelte"` + - 第二十行: `svelte(),` +4. 删掉 `tsconfig.json` 中 37 行 `"svelte"` +5. 重新执行 `pnpm i` diff --git a/src/hello.svelte b/src/hello.svelte index b619b3f..40d97b7 100644 --- a/src/hello.svelte +++ b/src/hello.svelte @@ -1,11 +1,9 @@ -