We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
老的版本 v5 是将 create-react-app 使用 TypeScript 重新实现了一遍,并添加了配置功能支持,维护成本越来越高,最终 v6 参考 @timarney 开发的 react-app-rewired 已相同的方式实现,虽然在 mocker-api 中使用过类似的玩法,但是没有想到去更改缓存中的内容来实现添加配置。
配置支持 .kktrc.js 和 .kktrc.ts,也可以不配置,将是少量更改的 create-react-app 玩儿法是一样的。
.kktrc.js
.kktrc.ts
- "doc": "cross-env ENTRYDIR=website kkt build", + "doc": "kkt build --app-src ./website", - "start": "cross-env ENTRYDIR=website kkt start", + "start": "kkt start --app-src ./website",
配置依然支持 kktrc.js 和 kktrc.ts 两种配置。
kktrc.js
kktrc.ts
- export const moduleScopePluginOpts = []; - export const loaderOneOf = []; - export const mocker = {}; - export function loaderDefault(loader) { - return loader; - } - export default (conf: webpack.Configuration, options: OptionConf, webpack: typeof webpack) => { - return conf; - } + export default (conf: Configuration, env: string, options: LoaderConfOptions) => { + return conf; + } + export const devServer = (configFunction: DevServerConfigFunction) => { + return (proxy: WebpackDevServer.ProxyConfigArrayItem[], allowedHost: string) => { + // Create the default config by calling configFunction with the proxy/allowedHost parameters + const config = configFunction(proxy, allowedHost); + return config; + } + }
- export const loaderOneOf = [ - require.resolve('@kkt/loader-less'), - ]; + import lessModules from '@kkt/less-modules'; export default (conf, env, options) => { + conf = lessModules(conf, env, options); return conf; }
- export const loaderOneOf = [ - require.resolve('@kkt/loader-scss'), - ];
- export const loaderOneOf = [ - require.resolve('@kkt/loader-stylus') - ]; + import stylusModules from '@kkt/stylus-modules'; export default (conf, env, options) => { + conf = stylusModules(conf, env, options); return conf; }
- export const mocker = { - path: path.resolve('./mocker/index.js'), - option: { - proxy: { - '/repos/(.*)': 'https://api.github.com/', - }, - changeHost: true, - }, - } + export const proxySetup = () => { + return { + path: path.resolve('./mocker/index.js'), + option: { + proxy: { + '/repos/(.*)': 'https://api.github.com/', + }, + changeHost: true, + } + } + }
npm install kkt --save-dev
"scripts": { - "start": "react-scripts start", + "start": "kkt start", - "build": "react-scripts build", + "build": "kkt build", - "test": "react-scripts test", + "test": "kkt test", "eject": "react-scripts eject" }
# Start the Dev Server $ npm start # Build your app $ npm run build
The text was updated successfully, but these errors were encountered:
"scripts": { - "start": "kkt watch", + "start": "BUILD_PATH=dist kkt start --watch --no-open-browser", - "build": "kkt build", + "build": "BUILD_PATH=dist kkt build", "test": "kkt test --env=jsdom", "test:coverage": "kkt test --env=jsdom --coverage" }
.env
INLINE_RUNTIME_CHUNK=false FAST_REFRESH=false BUILD_PATH=dist
Sorry, something went wrong.
No branches or pull requests
老的版本 v5 是将 create-react-app 使用 TypeScript 重新实现了一遍,并添加了配置功能支持,维护成本越来越高,最终 v6 参考 @timarney 开发的 react-app-rewired 已相同的方式实现,虽然在 mocker-api 中使用过类似的玩法,但是没有想到去更改缓存中的内容来实现添加配置。
配置支持
.kktrc.js
和.kktrc.ts
,也可以不配置,将是少量更改的 create-react-app 玩儿法是一样的。kkt 5.x to 6.x
设置入口目录
配置变得简单
配置依然支持
kktrc.js
和kktrc.ts
两种配置。Support for Less.
Support for scss.
Support for stylus.
Mocker API
How to kkt your create-react-app project
The text was updated successfully, but these errors were encountered: