Skip to content

Commit ba590f0

Browse files
committed
docs: update website packages
1 parent 43b6cdf commit ba590f0

34 files changed

+285
-632
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
*.DS_Store
22
*.idea
33
node_modules*
4-
static*
54
npm-debug.log
65
dist/*
76
idea/

website/blog/2019-05-28-first-blog-post.md

-12
This file was deleted.

website/blog/2019-05-29-long-blog-post.md

-44
This file was deleted.

website/blog/2021-08-01-mdx-blog-post.mdx

-20
This file was deleted.
Binary file not shown.

website/blog/2021-08-26-welcome/index.md

-25
This file was deleted.

website/blog/authors.yml

-17
This file was deleted.

website/docs/FAQ.md

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
sidebar_position: 4
3+
title: FAQ
4+
---
5+
6+
## How to override webpack configs
7+
You can override webpack configs via **ko.config.js**, and we recommend you override [copy-webpack-plugin](https://github.com/webpack-contrib/copy-webpack-plugin),[html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin) if needed. You can override like this:
8+
9+
``` js
10+
const CopyWebpackPlugin = require('copy-webpack-plugin');
11+
12+
const copyConfig = [
13+
{ from: path.resolve(__dirname, 'public/config'), to: 'config' },
14+
{ from: path.resolve(__dirname, 'public/assets'), to: 'assets' },
15+
]
16+
17+
module.exports = {
18+
... //other webpack configs
19+
plugins: [
20+
new CopyWebpackPlugin(copyConfig),
21+
],
22+
};
23+
24+
```
25+
26+
## How to polyfill Node.js core modules:
27+
28+
Webpack 5 no longer polyfills Node.js core modules automatically which means if you use them in your code running in browsers or alike, you will have to install compatible modules from npm and include them yourself. And if your target environment is browser, just install some packages and add **resolve.fallback** into **ko.config.js**.
29+
30+
### Install browserify packages:
31+
```bash
32+
pnpm add os-browserify crypto-browserify stream-browserify
33+
```
34+
35+
### Add configs into **ko.config.js**:
36+
37+
```js
38+
module.exports = {
39+
... //other webpack configs
40+
resolve: {
41+
fallback: {
42+
fs: false,
43+
path: false,
44+
events: false,
45+
os: require.resolve('os-browserify/browser'),
46+
crypto: require.resolve('crypto-browserify'),
47+
stream: require.resolve('stream-browserify'),
48+
},
49+
}
50+
};
51+
```
52+
53+
## How to use web workers
54+
55+
You can use [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) without [worker-loader](https://github.com/webpack-contrib/worker-loader) in ko, just like this:
56+
```js
57+
new Worker(new URL('./worker.js', import.meta.url));
58+
```
59+
And you should update your project **tsconfig.json** into these configs:
60+
```json
61+
"compilerOptions": {
62+
"module": "esnext",
63+
"moduleResolution": "Node"
64+
}
65+
```

website/docs/advanced/_category_.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "Advanced",
3+
"position": 5
4+
}

website/docs/advanced/architect.md

Whitespace-only changes.

website/docs/advanced/migration.md

Whitespace-only changes.

website/docs/cli/_category_.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "Command Line Interface",
3+
"position": 3
4+
}

website/docs/cli/ko-build.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
sidebar_position: 1
3+
title: ko build
4+
---
5+
6+
Use internal webpack instance to bundle files, compiled files will be write to **dist** directory by default. You can change this behavior via **ko.config.js**.
7+
8+
Optional arguments:
9+
10+
* `--hash`: output filename with it's hash
11+
* `-t,--ts,--typescript`: support typescript or not, ko support typescript by default
12+
* `-e,--esbuild`: enable esbuild (now only esbuild minification is supported)

website/docs/cli/ko-dev.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
sidebar_position: 2
3+
title: ko dev
4+
---
5+
6+
start a development server that provides live reloading. You can change development server default behaviors via **devServer** values in **ko.config.js**, or use cli arguments.
7+
8+
Optional arguments:
9+
* `-p, --port <port>`: server start on which port, a number value is accepted
10+
* `--host <host>`: server start on which host, you can specify an ip like **0.0.0.0**
11+
* `-t, --ts`: support typescript or not, ko support typescript by default
12+
* `-a,--analyzer`: show output files with an interactive zoomable treemap in **http://127.0.0.1:8888**

website/docs/cli/ko-eslint.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
sidebar_position: 3
3+
title: ko eslint
4+
---
5+
6+
Alias `ko el`
7+
8+
**Please note that `ko eslint` is experimental**
9+
10+
use **eslint** to format your codes, we collate an [eslint configuration](https://github.com/DTStack/ko/blob/master/packages/ko-config/eslint.js) and use it as default eslint configuration, you can override it via cli arguments.
11+
12+
## How to Use
13+
You can use `pnpm` or `npx` to run `ko eslint` on the command like this:
14+
15+
``` bash
16+
# Run on files:
17+
npx eslint file1.js
18+
# Run on multiple files via glob syntax
19+
npx ko eslint "src/**"
20+
```
21+
22+
## Optional arguments:
23+
24+
* `-f, --fix`: Fix problems automatically
25+
* `-c, --config <path>`: overriding default eslint config path, and use this configuration
26+
* `--ignore-path <ignorePath>`: Specify path of ignore file

website/docs/cli/ko-prettier.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
sidebar_position: 4
3+
title: ko prettier
4+
---
5+
6+
Alias `ko pr`
7+
8+
**Please note that `ko prettier` is experimental**
9+
10+
use **prettier** to format your codes, we collate an [prettier configuration](https://github.com/DTStack/ko/blob/master/packages/ko-config/prettier.js) and use it as default prettier configuration, you can override it via cli arguments.
11+
12+
## How to Use
13+
You can use `pnpm` or `npx` to run `ko prettier` on the command like this:
14+
15+
``` bash
16+
# Run on files:
17+
npx prettier file1.js
18+
# Run on multiple files via glob syntax
19+
npx ko prettier "src/**"
20+
```
21+
22+
## Optional arguments:
23+
24+
* `-w, --write`: Edit files in-place.
25+
* `-c, --config <path>`: overriding default prettier config path, and use this configuration
26+
* `--ignore-path <ignorePath>`: Specify path of ignore file

website/docs/cli/ko-stylelint.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
sidebar_position: 5
3+
title: ko stylelint
4+
---
5+
6+
Alias `ko sl`
7+
8+
**Please note that `ko stylelint` is experimental**
9+
10+
use **stylelint** to format your codes, we collate an [stylelint configuration](https://github.com/DTStack/ko/blob/master/packages/ko-config/stylelint.js) and use it as default stylelint configuration, you can override it via cli arguments.
11+
12+
## How to Use
13+
You can use `pnpm` or `npx` to run `ko stylelint` on the command like this:
14+
15+
``` bash
16+
# Run on files:
17+
npx stylelint file1.js
18+
# Run on multiple files via glob syntax
19+
npx ko stylelint "src/**"
20+
```
21+
22+
## Optional arguments:
23+
24+
* `-f, --fix`: Fix problems automatically
25+
* `-c, --config <path>`: overriding default eslint config path, and use this configuration
26+
* `--ignore-path <ignorePath>`: Specify path of ignore file

website/docs/contributing.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
sidebar_position: 6
3+
title: Contributing
4+
---
5+
6+
# Contributing to ko
7+
8+
We use **pnpm workspace** to manage our packages. so make sure you use **pnpm** as package manager than **npm** or **yarn**.
9+
10+
To getting started with this repo:
11+
12+
``` bash
13+
pnpm install
14+
```
15+
16+
## Code Structure
17+
18+
as a **monorepo**, ko now maintain 4 packages in packages directory:
19+
20+
* **ko**: main package
21+
* **ko-lints**: code format cli, include **eslint**, **prettier** and **stylelint**, can be integrated in ko or use individually
22+
* **ko-config**: default config used by **ko-lints**
23+
* **babel-preset-ko-app**: babel preset used by ko
24+
25+
## Commands
26+
27+
### Debug
28+
29+
use `pnpm debug` to debug local packages
30+
31+
### Local Testing
32+
33+
use **pnpm link** to link `ko` into local packages for testing

0 commit comments

Comments
 (0)