UNPKG

6.89 kBMarkdownView Raw
1<p align="center">
2 <a href="https://github.com/kktjs/kkt">
3 <img src="https://raw.githubusercontent.com/kktjs/kkt/d2bb00dc2d0bd9bb133f3a369d0ad2f5330ed4af/website/kkt.svg?sanitize=true">
4 </a>
5</p>
6
7<p align="center">
8 <a href="https://github.com/kktjs/kkt/issues">
9 <img src="https://img.shields.io/github/issues/kktjs/kkt.svg">
10 </a>
11 <a href="https://github.com/kktjs/kkt/network">
12 <img src="https://img.shields.io/github/forks/kktjs/kkt.svg">
13 </a>
14 <a href="https://github.com/kktjs/kkt/stargazers">
15 <img src="https://img.shields.io/github/stars/kktjs/kkt.svg">
16 </a>
17 <a href="https://github.com/kktjs/kkt/releases">
18 <img src="https://img.shields.io/github/release/kktjs/kkt.svg">
19 </a>
20 <a href="https://www.npmjs.com/package/kkt">
21 <img src="https://img.shields.io/npm/v/kkt.svg">
22 </a>
23</p>
24
25Create React apps with no build configuration, Cli tool for creating react apps. Another tool, [`kkt-ssr`](https://github.com/kktjs/kkt-ssr), Is a lightweight framework for static and server-rendered applications.
26
27> - [Migrate from kkt 5.x to 6.x](https://github.com/kktjs/kkt/issues/133).
28> - [Migrate from kkt 4.x to 5.x](https://github.com/kktjs/kkt-next/issues/1).
29
30As of `KKT 6.x` this repo is "lightly" maintained mostly by the community at this point.
31
32### Features:
33
34- ⏱ The code was rewritten using TypeScript.
35- ♻️ Recompile the code when project files get added, removed or modified.
36- 📚 Readable source code that encourages learning and contribution
37- ⚛️ Refactor code based on [**create-react-app**](https://github.com/facebook/create-react-app).
38- 💝 Expose the configuration file entry and support webpack configuration.
39- 🚀 Supports [**creat-kkt**](https://github.com/kktjs/create-kkt) to create different instances.
40- ⛑ Jest test runner setup with defaults `kkt test`
41
42## Usage
43
44You will need [`Node.js`](https://nodejs.org) installed on your system.
45
46```bash
47npm install kkt
48```
49
50## Example
51
52Initialize the project from one of the examples, Let's quickly create a react application:
53
54```bash
55$ npx create-kkt my-app -e uiw
56# or npm
57$ npm create kkt my-app -e `<Example Name>`
58# or yarn
59$ yarn create kkt my-app -e `<Example Name>`
60```
61
62- [**`basic`**](https://github.com/kktjs/kkt/tree/master/example/basic) - The [react](https://github.com/facebook/react) base application.
63- [**`bundle`**](https://github.com/kktjs/kkt/tree/master/example/bundle) - Package the UMD package for developing the React component library.
64- [**`electron`**](https://github.com/kktjs/kkt/tree/master/example/electron) - Use an example of [`Electronjs`](https://github.com/electron).
65- [**`less`**](https://github.com/kktjs/kkt/tree/master/example/less) - Use an example of `Less`.
66- [**`markdown`**](https://github.com/kktjs/kkt/tree/master/example/markdown) - Use an example of `Markdown`.
67- [**`react-component-tsx`**](https://github.com/kktjs/kkt/tree/master/example/react-component-tsx) - Create a project containing the website for the react component library.
68- [**`rematch-tsx`**](https://github.com/kktjs/kkt/tree/master/example/rematch-tsx) - Use [`Rematch`](https://github.com/rematch/rematch) example for TypeScript.
69- [**`rematch`**](https://github.com/kktjs/kkt/tree/master/example/rematch) - Use [`Rematch`](https://github.com/rematch/rematch) for the project.
70- [**`scss`**](https://github.com/kktjs/kkt/tree/master/example/scss) - Use an example of `Scss`.
71- [**`stylus`**](https://github.com/kktjs/kkt/tree/master/example/stylus) - Use an example of `Stylus`.
72- [**`typescript`**](https://github.com/kktjs/kkt/tree/master/example/typescript) - Use an example of `TypeScript`.
73- [**`uiw`**](https://github.com/kktjs/kkt/tree/master/example/uiw) - Use [`uiw`](https://uiwjs.github.io/) for the project.
74
75## Configuration
76
77Supports `kktrc.js` and `kktrc.ts`.
78
79```ts
80import { ParsedArgs } from 'minimist';
81import { LoaderConfOptions, DevServerConfigFunction } from 'kkt';
82
83type KKTRC = {
84 devServer?: (configFunction: DevServerConfigFunction, evn: string,) => DevServerConfigFunction;
85 default?: (conf: Configuration, evn: string, options: LoaderConfOptions) => Configuration;
86}
87type DevServerConfigFunction = (proxy: WebpackDevServer.ProxyConfigArrayItem[], allowedHost: string)
88 => WebpackDevServer.Configuration;
89```
90
91Example
92
93```ts
94import webpack, { Configuration } from 'webpack';
95import WebpackDevServer from 'webpack-dev-server';
96import lessModules from '@kkt/less-modules';
97import { LoaderConfOptions } from 'kkt';
98
99export default (conf: Configuration, env: string, options: LoaderConfOptions) => {
100 // The Webpack config to use when compiling your react app for development or production.
101 // ...add your webpack config
102 conf = lessModules(conf, env, options);
103 return conf;
104}
105
106export const devServer = (configFunction: DevServerConfigFunction) => {
107 return (proxy: WebpackDevServer.ProxyConfigArrayItem[], allowedHost: string) => {
108 // Create the default config by calling configFunction with the proxy/allowedHost parameters
109 const config = configFunction(proxy, allowedHost);
110
111 // Change the https certificate options to match your certificate, using the .env file to
112 // set the file paths & passphrase.
113 const fs = require('fs');
114 config.https = {
115 key: fs.readFileSync(process.env.REACT_HTTPS_KEY, 'utf8'),
116 cert: fs.readFileSync(process.env.REACT_HTTPS_CERT, 'utf8'),
117 ca: fs.readFileSync(process.env.REACT_HTTPS_CA, 'utf8'),
118 passphrase: process.env.REACT_HTTPS_PASS
119 };
120
121 // Return your customised Webpack Development Server config.
122 return config;
123 }
124}
125```
126
127### Home Page
128
129Add `homepage` to `package.json`
130
131> The step below is important!
132
133Open your package.json and add a homepage field for your project:
134
135```json
136"homepage": "https://myusername.github.io/my-app",
137```
138
139or for a GitHub user page:
140
141```json
142"homepage": "https://myusername.github.io",
143```
144
145or for a custom domain page:
146
147```json
148"homepage": "https://mywebsite.com",
149```
150
151KKT uses the `homepage` field to determine the root URL in the built HTML file.
152
153### Plugins & Loader
154
155- [@kkt/less-modules](https://github.com/kktjs/kkt/tree/master/packages/less-modules)
156- [@kkt/mocker-api](https://github.com/kktjs/kkt/tree/master/packages/mocker-api)
157- [@kkt/raw-modules](https://github.com/kktjs/kkt/tree/master/packages/raw-modules)
158- [@kkt/react-library](https://github.com/kktjs/kkt/tree/master/packages/react-library)
159- [@kkt/scope-plugin-options](https://github.com/kktjs/kkt/tree/master/packages/scope-plugin-options)
160- [@kkt/stylus-modules](https://github.com/kktjs/kkt/tree/master/packages/stylus-modules)
161
162### Development
163
164```bash
165npm run hoist
166
167npm run lib:watch
168npm run kkt:watch
169```
170
171### Acknowledgements
172
173[@timarney](https://github.com/timarney) for having created [react-app-rewired](https://github.com/timarney/react-app-rewired).
174
175## License
176
177[MIT © Kenny Wong](./LICENSE)