-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example(react-component-tsx): update example.
- Loading branch information
1 parent
b9dc330
commit ca5e694
Showing
19 changed files
with
180 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
import path from 'path'; | ||
import { OptionConf } from 'kkt'; | ||
import webpack from 'webpack'; | ||
import webpack, { Configuration } from 'webpack'; | ||
import { DevServerConfigFunction, LoaderConfOptions } from 'kkt'; | ||
import WebpackDevServer from 'webpack-dev-server'; | ||
import lessModules from '@kkt/less-modules'; | ||
import rawModules from '@kkt/raw-modules'; | ||
import scopePluginOptions from '@kkt/scope-plugin-options'; | ||
import pkg from './package.json'; | ||
|
||
type Webpack = typeof webpack; | ||
|
||
export const loaderOneOf = [require.resolve('@kkt/loader-less')]; | ||
|
||
export default (conf: webpack.Configuration, opts: OptionConf, webpack: Webpack) => { | ||
const pkg = require(path.resolve(process.cwd(), 'package.json')); | ||
// 获取版本 | ||
export default (conf: Configuration, env: string, options: LoaderConfOptions) => { | ||
conf = rawModules(conf, env, { ...options }); | ||
conf = scopePluginOptions(conf, env, { | ||
...options, | ||
allowedFiles: [path.resolve(process.cwd(), 'README.md')], | ||
}); | ||
conf = lessModules(conf, env, options); | ||
// Get the project version. | ||
conf.plugins!.push( | ||
new webpack.DefinePlugin({ | ||
VERSION: JSON.stringify(pkg.version), | ||
}), | ||
); | ||
|
||
conf.output = { ...conf.output, publicPath: './' }; | ||
return conf; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
**/*.md | ||
**/*.svg | ||
**/*.ejs | ||
**/*.yml | ||
package.json | ||
node_modules | ||
dist | ||
build | ||
lib | ||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"printWidth": 120, | ||
"overrides": [ | ||
{ | ||
"files": ".prettierrc", | ||
"options": { "parser": "json" } | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,37 @@ | ||
react-component-tsx | ||
React Component Example for TypeScript. | ||
=== | ||
|
||
为 React 组件库创建一个项目,包含组件库实例预览的网站。文档与组件库放入一个工程中,全部使用 TypeScript 编写,React 组件库源文件放入 `src` 目录 ,文档网站源文件放入 `website` 目录。 | ||
Create a project for the React component library containing a website preview of the component library instance. The documents and component libraries are put into a project, all written in `TypeScript`, the component library source files are added to the `src` directory, and the document website source files are added to the `website` directory. | ||
|
||
## 开发模式 | ||
## Open in CodeSandbox | ||
|
||
[![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?logo=codesandbox)](https://codesandbox.io/s/github/jaywcjlove/example/react-component-tsx) | ||
|
||
## Quick Start | ||
|
||
```bash | ||
npm install | ||
``` | ||
|
||
**development** | ||
|
||
Runs the project in development mode. | ||
|
||
```bash | ||
# 第一步,先运行,监听组件编译输出 .js 文件 | ||
npm run ts:watch | ||
# 第二步,监听编译输出类型 .d.ts 文件 | ||
npm run types:watch | ||
# 第三步,开发模式,监听编译预览网站实例 | ||
npm run doc:dev | ||
# Step 1, run first, listen to the component compile and output the .js file | ||
# listen for compilation output type .d.ts file | ||
npm run watch | ||
# Step 2, development mode, listen to compile preview website instance | ||
npm run start | ||
``` | ||
|
||
编译发布 | ||
**production** | ||
|
||
Builds the app for production to the build folder. | ||
|
||
```bash | ||
npm run released | ||
``` | ||
npm run build | ||
``` | ||
|
||
The build is minified and the filenames include the hashes. | ||
Your app is ready to be deployed! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"template": "node" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,6 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="react" /> | ||
/// <reference types="react-dom" /> | ||
|
||
declare namespace NodeJS { | ||
interface ProcessEnv { | ||
readonly NODE_ENV: 'development' | 'production' | 'test'; | ||
readonly PUBLIC_URL: string; | ||
} | ||
} | ||
|
||
declare module '*.bmp' { | ||
const src: string; | ||
export default src; | ||
} | ||
|
||
declare module '*.gif' { | ||
const src: string; | ||
export default src; | ||
} | ||
|
||
declare module '*.jpg' { | ||
const src: string; | ||
export default src; | ||
} | ||
|
||
declare module '*.jpeg' { | ||
const src: string; | ||
export default src; | ||
} | ||
|
||
declare module '*.png' { | ||
const src: string; | ||
export default src; | ||
} | ||
|
||
declare module '*.webp' { | ||
const src: string; | ||
export default src; | ||
} | ||
|
||
declare module '*.svg' { | ||
import * as React from 'react'; | ||
|
||
export const ReactComponent: React.FunctionComponent<React.SVGProps<SVGSVGElement>>; | ||
|
||
const src: string; | ||
export default src; | ||
} | ||
/// <reference types="react-scripts" /> | ||
|
||
declare module '*.module.less' { | ||
const classes: { readonly [key: string]: string }; | ||
export default classes; | ||
} | ||
|
||
declare module '*.less' { | ||
const src: string; | ||
export default src; | ||
} | ||
declare module '*.module.css' { | ||
const classes: { readonly [key: string]: string }; | ||
export default classes; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.