# Svelte项目验证Demo **Repository Path**: szuscn/svelte-project-demo ## Basic Information - **Project Name**: Svelte项目验证Demo - **Description**: Svelte项目上手验证测试Demo 注意:Svelte 官方已经停止维护,不在有新的更新,对于想要上手svelte的只可以作为一个参考,新版本的SvelteKit地址(https://kit.svelte.dev/) 1、路由安装使用:svelte-spa-router 2、基础组件封装组合测试 3、公共样式处理 4、Rollup配置问题处理 - **Primary Language**: JavaScript - **License**: GPL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2022-12-05 - **Last Updated**: 2022-12-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 克隆官方示例svelte项目 ```bash npx degit sveltejs/template svelte-app cd svelte-app ``` *Note that you will need to have [Node.js](https://nodejs.org) installed.* ## 进入项目 对项目进行初始还原 ```bash cd svelte-app npm install ``` 启动项目 ```bash npm run dev ``` Navigate to [localhost:8080](http://localhost:8080). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes. By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`. If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense. ## 项目打包 To create an optimised version of the app: ```bash npm run build ``` You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com). ## 单页应用程序模式 ```js "start": "sirv public --single" ``` ## 使用 TypeScript This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with: ```bash node scripts/setupTypeScript.js ``` Or remove the script via: ```bash rm scripts/setupTypeScript.js ``` If you want to use `baseUrl` or `path` aliases within your `tsconfig`, you need to set up `@rollup/plugin-alias` to tell Rollup to resolve the aliases. For more info, see [this StackOverflow question](https://stackoverflow.com/questions/63427935/setup-tsconfig-path-in-svelte). ## svelte项目部署 ### With [Vercel](https://vercel.com) Install `vercel` if you haven't already: ```bash npm install -g vercel ``` Then, from within your project folder: ```bash cd public vercel deploy --name my-project ``` ### With [surge](https://surge.sh/) Install `surge` if you haven't already: ```bash npm install -g surge ``` Then, from within your project folder: ```bash npm run build surge public my-project.surge.sh ```