vite-riot-template/README.md

88 lines
2.4 KiB
Markdown
Raw Normal View History

2022-07-07 02:32:19 +00:00
# Vite RiotJS Template
Use [Vite](https://vitejs.dev/) Starter Template to scaffold a new [Riot](https://riot.js.org/) project.
2022-07-18 04:19:13 +00:00
2022-07-07 02:32:19 +00:00
## Getting Started
Pull the template files with [degit](https://github.com/Rich-Harris/degit) and install dependencies
```
npx degit n2geoff/vite-riot-template my-project
cd my-project
npm install
npm run dev
2022-07-07 02:34:10 +00:00
```
2022-07-07 02:32:19 +00:00
2022-07-28 22:47:01 +00:00
### Checklist
When you use this template, you should update the following with your information
- [ ] Update `package.json` information
- [ ] Change the author name in `LICENSE`
- [ ] Change the favicon in `public`
- [ ] Clean up the README
### Project Structure
```
dist/ <-- `npm run build` app
src/ <-- your source code
css/ <-- processed css files
js/ <-- processed javascript files
public/ <-- unprocessed static `/` assets
2022-07-29 04:14:19 +00:00
components/ <-- riots components
2022-07-28 22:47:01 +00:00
hello-riot/
hello-riot.riot <-- riot component
2022-07-29 04:14:19 +00:00
hello-riot.spec.js <-- component tests
2023-03-02 19:29:00 +00:00
app.js <-- app initialization
2022-07-28 22:47:01 +00:00
index.html <-- START HERE
vite.config.js <-- build configuration
README.md
... <-- misc project meta files
```
2022-07-18 04:19:13 +00:00
### Mounting Strategy
2023-03-02 19:29:00 +00:00
This template automaticly registers and mounts riot components. These global **components** can in-turn can mount other nested components via `components` export option.
2022-07-18 04:19:13 +00:00
2022-07-29 04:25:05 +00:00
#### Example
2022-07-18 04:19:13 +00:00
```
2022-07-29 04:14:19 +00:00
// my-page.riot
2022-07-18 04:19:13 +00:00
<my-page>
<div>
<example-component></example-component>
</div>
<script>
import Example from './example-component/example-component.riot';
export default {
components: {
Example
}
}
</script>
</my-page>
```
2023-03-02 19:29:00 +00:00
> SEE: `/src/app.js` for more information
2022-07-29 02:45:51 +00:00
2022-07-18 04:19:13 +00:00
2022-07-07 02:32:19 +00:00
## NPM Scripts
2022-07-29 02:45:51 +00:00
- `npm run dev` - Starts the development server at port 3000
- `npm run build` - Builds the application in a dist folder
- `npm run preview` - Serves the build files (dist folder) locally at port 5000
2022-07-07 02:32:19 +00:00
> Note that if after this last command you do not see anything, you can use instead this other command:
`npm run preview --host` - You should then be able to see your files locally at port 5000
2022-07-18 04:19:13 +00:00
2022-07-07 02:32:19 +00:00
## License
2022-07-18 03:53:56 +00:00
- [MIT License](https://github.com/n2geoff/vite-riot-template/blob/main/LICENSE).