Skip to content

Commit

Permalink
chore: rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
poyoho committed Jan 28, 2022
2 parents ed4af2d + 4bf3d51 commit fc1caa4
Show file tree
Hide file tree
Showing 81 changed files with 5,303 additions and 206 deletions.
2,738 changes: 2,738 additions & 0 deletions .github/issue-workflow.excalidraw

Large diffs are not rendered by default.

Binary file modified .github/issue-workflow.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,954 changes: 1,954 additions & 0 deletions .github/pr-workflow.excalidraw

Large diffs are not rendered by default.

Binary file modified .github/pr-workflow.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ We already have many config options, and we should avoid fixing an issue by addi

If you would like to start a translation in your language, you are welcome to contribute! Please join [the #translations channel in Vite Land](https://chat.vitejs.dev) to discuss and coordinate with others.

The english docs are embeded in the main Vite repo, to allow contributors to work on docs, tests and implementation in the same PR. Translations are done by forking the main repo.
The english docs are embedded in the main Vite repo, to allow contributors to work on docs, tests and implementation in the same PR. Translations are done by forking the main repo.

### How to start a translation repo

Expand All @@ -207,4 +207,4 @@ The english docs are embeded in the main Vite repo, to allow contributors to wor
4. Push your commits to your Github repo. you can setup a netlify preview as well.
5. Use [Ryu-cho](https://github.com/vuejs-translations/ryu-cho) tool to setup a Github Action, automatically track English docs update later.

We recommend talking with others in Vite Land so you find more contributors for your language to share the maintainance work. Once the translation is done, communicate it to the Vite team so the repo can be moved to the official vitejs org in GitHub.
We recommend talking with others in Vite Land so you find more contributors for your language to share the maintenance work. Once the translation is done, communicate it to the Vite team so the repo can be moved to the official vitejs org in GitHub.
4 changes: 2 additions & 2 deletions docs/.vitepress/theme/sponsors.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

.sponsors a {
color: #999;
margin: 1em;
margin: 1em 2em;
display: block;
}

Expand Down Expand Up @@ -45,7 +45,7 @@
.gold-sponsors {
display: flex;
flex-wrap: wrap;
justify-content: space-evenly;
justify-content: center;
align-items: center;
}

Expand Down
6 changes: 6 additions & 0 deletions docs/.vitepress/theme/sponsors.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
"src": "/stackblitz.svg",
"tier": "platinum"
},
{
"id": "cypress",
"name": "Cypress.io",
"href": "https://cypress.io",
"src": "/cypress.svg"
},
{
"id": "tailwind",
"name": "Tailwind Labs",
Expand Down
18 changes: 16 additions & 2 deletions docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ You can also explicitly specify a config file to use with the `--config` CLI opt
vite --config my-config.js
```

Note that Vite will replace `__filename`, `__dirname`, and `import.meta.url`. Using these as variable names will result in an error:

```js
const __filename = "value"
// will be transformed to
const "path/vite.config.js" = "value"
```

### Config Intellisense

Since Vite ships with TypeScript typings, you can leverage your IDE's intellisense with jsdoc type hints:
Expand Down Expand Up @@ -169,7 +177,7 @@ export default defineConfig(async ({ command, mode }) => {
- **Type:** `string`
- **Default:** `"node_modules/.vite"`

Directory to save cache files. Files in this directory are pre-bundled deps or some other cache files generated by vite, which can improve the performance. You can use `--force` flag or manually delete the directory to regenerate the cache files. The value can be either an absolute file system path or a path relative to project root.
Directory to save cache files. Files in this directory are pre-bundled deps or some other cache files generated by vite, which can improve the performance. You can use `--force` flag or manually delete the directory to regenerate the cache files. The value can be either an absolute file system path or a path relative to project root. Default to `.vite` when no package.json is detected.

### resolve.alias

Expand Down Expand Up @@ -474,6 +482,11 @@ export default defineConfig(async ({ command, mode }) => {
configure: (proxy, options) => {
// proxy will be an instance of 'http-proxy'
}
},
// Proxying websockets or socket.io
'/socket.io': {
target: 'ws://localhost:3000',
ws: true
}
}
}
Expand Down Expand Up @@ -584,6 +597,7 @@ createServer()

- contains `workspaces` field in `package.json`
- contains one of the following file
- `lerna.json`
- `pnpm-workspace.yaml`

Accepts a path to specify the custom workspace root. Could be a absolute path or a path relative to [project root](/guide/#index-html-and-project-root). For example:
Expand Down Expand Up @@ -845,7 +859,7 @@ export default defineConfig({
### preview.port

- **Type:** `number`
- **Default:** `5000`
- **Default:** `4173`

Specify server port. Note if the port is already being used, Vite will automatically try the next available port so this may not be the actual port the server ends up listening on.

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/env-and-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ interface ImportMeta {

## Modes

By default, the dev server (`dev` command) runs in `development` mode and the `build` and `serve` commands run in `production` mode.
By default, the dev server (`dev` command) runs in `development` mode and the `build` command run in `production` mode.

This means when running `vite build`, it will load the env variables from `.env.production` if there is one:

Expand Down
6 changes: 3 additions & 3 deletions docs/guide/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,13 @@ That said, Vite does provide built-in support for `.scss`, `.sass`, `.less`, `.s

```bash
# .scss and .sass
npm install -D sass
npm add -D sass

# .less
npm install -D less
npm add -D less

# .styl and .stylus
npm install -D stylus
npm add -D stylus
```

If using Vue single file components, this also automatically enables `<style lang="sass">` et al.
Expand Down
6 changes: 3 additions & 3 deletions docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Vite requires [Node.js](https://nodejs.org/en/) version >=12.2.0. However, some
With NPM:

```bash
$ npm init vite@latest
$ npm create vite@latest
```

With Yarn:
Expand All @@ -65,10 +65,10 @@ You can also directly specify the project name and the template you want to use

```bash
# npm 6.x
npm init vite@latest my-vue-app --template vue
npm create vite@latest my-vue-app --template vue

# npm 7+, extra double-dash is needed:
npm init vite@latest my-vue-app -- --template vue
npm create vite@latest my-vue-app -- --template vue

# yarn
yarn create vite my-vue-app --template vue
Expand Down
5 changes: 2 additions & 3 deletions docs/guide/ssr.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Here `vite` is an instance of [ViteDevServer](./api-javascript#vitedevserver). `
The next step is implementing the `*` handler to serve server-rendered HTML:
```js
app.use('*', async (req, res) => {
app.use('*', async (req, res, next) => {
const url = req.originalUrl

try {
Expand Down Expand Up @@ -134,8 +134,7 @@ app.use('*', async (req, res) => {
// If an error is caught, let Vite fix the stracktrace so it maps back to
// your actual source code.
vite.ssrFixStacktrace(e)
console.error(e)
res.status(500).end(e.message)
next(e)
}
})
```
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/using-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Vite can be extended using plugins, which are based on Rollup's well-designed pl
To use a plugin, it needs to be added to the `devDependencies` of the project and included in the `plugins` array in the `vite.config.js` config file. For example, to provide support for legacy browsers, the official [@vitejs/plugin-legacy](https://github.com/vitejs/vite/tree/main/packages/plugin-legacy) can be used:

```
$ npm i -D @vitejs/plugin-legacy
$ npm add -D @vitejs/plugin-legacy
```

```js
Expand Down
22 changes: 22 additions & 0 deletions docs/public/cypress.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
"engines": {
"node": ">=12.2.0"
},
"homepage": "https://vitejs.dev/",
"keywords": [
"frontend",
"hmr",
"dev-server",
"build-tool",
"vite"
],
"scripts": {
"preinstall": "npx only-allow pnpm",
"format": "prettier --write .",
Expand Down
6 changes: 3 additions & 3 deletions packages/create-vite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
With NPM:

```bash
$ npm init vite@latest
$ npm create vite@latest
```

With Yarn:
Expand All @@ -29,10 +29,10 @@ You can also directly specify the project name and the template you want to use

```bash
# npm 6.x
npm init vite@latest my-vue-app --template vue
npm create vite@latest my-vue-app --template vue

# npm 7+, extra double-dash is needed:
npm init vite@latest my-vue-app -- --template vue
npm create vite@latest my-vue-app -- --template vue

# yarn
yarn create vite my-vue-app --template vue
Expand Down
15 changes: 9 additions & 6 deletions packages/create-vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const {
blue,
magenta,
lightRed,
red
red,
reset
} = require('kolorist')

const cwd = process.cwd()
Expand Down Expand Up @@ -141,7 +142,7 @@ async function init() {
{
type: targetDir ? null : 'text',
name: 'projectName',
message: 'Project name:',
message: reset('Project name:'),
initial: defaultProjectName,
onState: (state) =>
(targetDir = state.value.trim() || defaultProjectName)
Expand All @@ -168,7 +169,7 @@ async function init() {
{
type: () => (isValidPackageName(targetDir) ? null : 'text'),
name: 'packageName',
message: 'Package name:',
message: reset('Package name:'),
initial: () => toValidPackageName(targetDir),
validate: (dir) =>
isValidPackageName(dir) || 'Invalid package.json name'
Expand All @@ -178,8 +179,10 @@ async function init() {
name: 'framework',
message:
typeof template === 'string' && !TEMPLATES.includes(template)
? `"${template}" isn't a valid template. Please choose from below: `
: 'Select a framework:',
? reset(
`"${template}" isn't a valid template. Please choose from below: `
)
: reset('Select a framework:'),
initial: 0,
choices: FRAMEWORKS.map((framework) => {
const frameworkColor = framework.color
Expand All @@ -193,7 +196,7 @@ async function init() {
type: (framework) =>
framework && framework.variants ? 'select' : null,
name: 'variant',
message: 'Select a variant:',
message: reset('Select a variant:'),
// @ts-ignore
choices: (framework) =>
framework.variants.map((variant) => {
Expand Down
3 changes: 1 addition & 2 deletions packages/create-vite/template-lit-ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "./types",
"rootDir": "./src",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
Expand All @@ -18,5 +17,5 @@
"useDefineForClassFields": false
},
"include": ["src/**/*.ts"],
"exclude": []
"references": [{ "path": "./tsconfig.node.json" }]
}
8 changes: 8 additions & 0 deletions packages/create-vite/template-lit-ts/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"composite": true,
"module": "esnext",
"moduleResolution": "node"
},
"include": ["vite.config.ts"]
}
3 changes: 2 additions & 1 deletion packages/create-vite/template-preact-ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment"
},
"include": ["src"]
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
8 changes: 8 additions & 0 deletions packages/create-vite/template-preact-ts/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"composite": true,
"module": "esnext",
"moduleResolution": "node"
},
"include": ["vite.config.ts"]
}
3 changes: 2 additions & 1 deletion packages/create-vite/template-react-ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["./src"]
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
8 changes: 8 additions & 0 deletions packages/create-vite/template-react-ts/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"composite": true,
"module": "esnext",
"moduleResolution": "node"
},
"include": ["vite.config.ts"]
}
3 changes: 2 additions & 1 deletion packages/create-vite/template-svelte-ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"allowJs": true,
"checkJs": true
},
"include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte"]
"include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte"],
"references": [{ "path": "./tsconfig.node.json" }]
}
8 changes: 8 additions & 0 deletions packages/create-vite/template-svelte-ts/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"composite": true,
"module": "esnext",
"moduleResolution": "node"
},
"include": ["vite.config.ts"]
}
2 changes: 1 addition & 1 deletion packages/create-vite/template-vanilla-ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"noUnusedParameters": true,
"noImplicitReturns": true
},
"include": ["./src"]
"include": ["src"]
}
3 changes: 2 additions & 1 deletion packages/create-vite/template-vue-ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"esModuleInterop": true,
"lib": ["esnext", "dom"]
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
}
8 changes: 8 additions & 0 deletions packages/create-vite/template-vue-ts/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"composite": true,
"module": "esnext",
"moduleResolution": "node"
},
"include": ["vite.config.ts"]
}
6 changes: 6 additions & 0 deletions packages/playground/assets/__tests__/assets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ describe('raw references from /public', () => {
})
})

test('import-expression from simple script', async () => {
expect(await page.textContent('.import-expression')).toMatch(
'[success][success]'
)
})

describe('asset imports from js', () => {
test('relative', async () => {
expect(await page.textContent('.asset-import-relative')).toMatch(assetMatch)
Expand Down

0 comments on commit fc1caa4

Please sign in to comment.