• Stars
    star
    171
  • Rank 222,266 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 2 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Modularization best practice to common web development scenarios, applies to vue/react/... any framework

Licence TypeScript

Vite How-to Guide

There are plenty of tutorials on how to use vite to compile code written in latest and hottest technology, this guide is different. It is about how to split application into files/packages, how to use TypeScript to ensure compatibility, how to use Vite to link them back (either statically or dynamically). Demo code is written in plain old javascript using vanilla web api.

I write this "Vite How-to Guide" after I have read tons of Webpack/SSR/Typescript guide on the internet. They try to tell you a series of command to follow blindly without a understanding of the essential problems. Also the solution is coupled with specific frontend framework and plugins to be "one key solution". But all those encapsulation makes debugging harder. In this guide, I will tell you how to write minimal vite (without plugins) and typescript configuration to do it yourself. You know what is the essential problem, you understand the theory, you copy paste the solution, then you can modify it confidently when problem arises.

The guide is still work in progress, you can join the discussion with author and readers #1

Problems are more important than the solutions

For each topic, there are 4 parts

  • The desired source code file/directory structure, and the motivation
  • What are the developer experience problems if structured this way
  • What are the user experience problems if structured this way
  • Solution walk through

Solution tend to change rapidly, for example webpack evolves into vite. But some problems are decades old, they seldom change. Understand the problems allow us to pick up new framework/tool faster, because you know what you are looking for.

You can reuse these examples as starter template

Download and install https://pnpm.io/ Run pnpm install to install dependencies of all packages in the workspace.

In each package, run pnpm dev to start dev server, run pnpm build && pnpm preview to start production server. Make some changes to deepen your understanding.

Every example is a starter template you can reuse by copy & paste. It works better this way, than reuse by framework with lots of options & callbacks.

More Repositories

1

awesome-lowcode

国内低代码平台从业者交流
13,236
star
2

modularization-examples

代码防腐实用技术
1,147
star
3

es-monitor

query metric from elasticsearch using sql
Python
262
star
4

12fallacy

打造杰出软件开发团队的12条指导建议
83
star
5

awesome-debugger

record & replay or time travel debugging
61
star
6

define-function

quick.js based eval
JavaScript
36
star
7

go-php7

bind php7 to go environment
Go
34
star
8

modern-cpp-howto

C++
28
star
9

toolchain

km of toolchain
Java
18
star
10

motrix

alternative reality
Go
17
star
11

learn-llama

my personal learning log
Python
14
star
12

vue-component-preview

preview individual vue component without running the full application
Vue
14
star
13

awesome-html

collection of "html over the wire" libraries
12
star
14

vite-ioc-demo

Inversion of Control (IoC) via vite in build time, a simple yet powerful way to modularize code
TypeScript
10
star
15

tsdb-book

9
star
16

repo-to-prompt

combine source code files into single prompt to chat with your repository
JavaScript
8
star
17

sslcode

start a https protected coding environment
JavaScript
7
star
18

vue-db

Get rid of as many mutable states as possible
TypeScript
5
star
19

daili

proxy based on java kilim coroutine
Java
4
star
20

vue-fusion

微信小程序的 SSR / OTA / HMR 解决方案,用熟悉的 Vue + TSX 写界面
TypeScript
3
star
21

readable

examples of readable code
Java
3
star
22

lambdafs

apply a lambda on your file system
Go
3
star
23

colorfour

real world business process modeling
Go
3
star
24

bayberry

Complement test frameworks with dependency injection, data injection and test helpers
Java
3
star
25

pythonic-modern-cpp

Collection of modern c++ code examples for python developers
C++
3
star
26

go-libc

intercept libc networking call to golang netpoller
C
2
star
27

plug-and-play

即插即玩的游戏掌机,可用 usb 接任意的设备当游戏主机
2
star
28

emscripten-howto

demo emscripten usage
JavaScript
2
star
29

refactor-by-example

TypeScript
2
star
30

wasm3.js

compile wasm3 using emscripten
C
1
star
31

react-sui-l0vyg3uq

Technology Sample you can rely on to build your own Design System, based on React and a System UI theme (Theme UI | styled-components).
TypeScript
1
star
32

game-of-life

Go
1
star
33

awesome-bayesian-approximation

algorithms to approximate the likelihood function in situations where its analytic form is intractable
1
star
34

incremental-html

update ui incrementally with html
TypeScript
1
star