Code Monkey home page Code Monkey logo

vite's Introduction

vite

No-bundle Dev Server for Vue Single-File Components

⚠️ Warning: Experimental ⚠️

Create the following files:

index.html

<div id="app"></div>
<script type="module">
import { createApp } from 'vue'
import Comp from './Comp.vue'

createApp(Comp).mount('#app')
</script>

Comp.vue

<template>
  <button @click="count++">{{ count }}</button>
</template>

<script>
export default {
  data: () => ({ count: 0 })
}
</script>

<style scoped>
button { color: red }
</style>

Then run:

npx vite

Go to http://localhost:3000, edit the .vue file to see changes hot-updated instantly.

How It Works

  • Imports are requested by the browser as native ES module imports - there's no bundling.

  • The server intercepts requests to *.vue files, compiles them on the fly, and sends them back as JavaScript.

  • Imports to npm packages inside .js files (and in <script> of index.html) are re-written on the fly to point to locally installed files (only packages that provide ES module builds will work - "module" field will be used if present in package.json). There is also plans to integrate with Snowpack to leverage its web_modules.

  • For libraries that provide ES modules builds that work in browsers, you can also directly import them from a CDN.

TODOs

  • SourceMap
  • Snowpack integration
  • Custom imports map support

vite's People

Contributors

yyx990803 avatar zzetao avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.