Just one of the things I'm learning. https://github.com/hchiam/learning
To install vite globally: npm install -g vite
Quick tip/reminder: already installed vite? If you have an index.html file in the current directory, just run this:
viteSpeed up server start and development by leveraging modern ES modules in the browser for faster development time. Vite transforms and serves source code only on demand. You still will want to bundle for production or final testing, but not during development where files are constantly being updated. Vite can translate import { someMethod } from 'my-dep' for the browser, so you don't have to think about it. Out of the box, you can directly import .ts files (and other file types too), and @import CSS files or import classes from './example.module.css'. Vite comes with things like code-splitting and load optimizations on by default.
https://github.com/vitejs/vite
<script src="index.js"></script>needs to be
<script type="module" src="index.js"></script>https://vite.new/{template} <-- see template link list
Using yarn:
yarn create vite
# and follow promptsOr with npm:
npm init vite@latest
# and follow promptsThen cd into the project folder and run yarn; yarn dev
{
"scripts": {
"dev": "vite", // start dev server, aliases: `vite dev`, `vite serve`
"build": "vite build", // build for production
"preview": "vite preview" // locally preview production build
}
}https://github.com/hchiam/vite-project-example-minimal
Using yarn: (triple-click to select all)
git clone https://github.com/hchiam/learning-vite.git && cd learning-vite/vite-project-example && yarn && yarn dev;Or with npm: (triple-click to select all)
git clone https://github.com/hchiam/learning-vite.git && cd learning-vite/vite-project-example && npm install && npm run dev;Then open http://localhost:3000
{
"scripts": {
"dev": "vite", // start dev server, aliases: `vite dev`, `vite serve`
"build": "vite build", // build for production
"preview": "vite preview" // locally preview production build
}
}vite.config.js:
import { defineConfig } from "vite";
export default defineConfig({
server: {
open: "demo.html",
},
});- this will open a new tab/window to http://localhost:5173/demo.html with
vite --config vite.config.jsor justvite