26
loading...
This website collects cookies to deliver better user experience
npm init @vitejs/app
yarn create @vitejs/app
? Select a framework:
> *vanilla*
> *vanilla*
vanilla ts
vue
react
react
preact
lit-element
svelte
cd *your project name*
npm install
npm run dev
<div id="app'></div>
.import './style.css'
imports all your css styling in your index.html file through main.js. NOTE: If you have deleted <div id="app'></div>
then you need to delete everything that's in the file except the import './style.css'
.env
file are environmental variables which help you secure something private from users like an API key. Vite exposes env variables on the special import.meta.env
object. So, let's create a file called .env in the project's root directory. Vite official documentation page says to start your env variables with VITE, for example VITE_API_KEYconst { resolve } = require('path')
module.exports = {
build: {
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html'),
*your page name*: resolve(__dirname, *your page directory*)
}
}
}
}
vite.config.js
file.npm run dev
and it will create a dist folder in your root directory and you can easily drag n drop or push it to your GitHub pages or Netlify.