@variousjs/create 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/copy.js +6 -1
- package/demo/dist/card.js +1 -1
- package/demo/dist/card.js.map +1 -1
- package/demo/dist/entry.js +1 -1
- package/demo/dist/entry.js.map +1 -1
- package/demo/dist/top.js +2 -0
- package/demo/dist/top.js.map +1 -0
- package/demo/index.html +8 -16
- package/package-lock.json.copy +371 -351
- package/package.json +6 -6
- package/package.json.copy +5 -5
- package/src/components/card.tsx +2 -1
- package/src/components/top.tsx +54 -0
- package/src/entry/container.tsx +9 -49
- package/{webpack.base.config.js → webpack/base.js} +10 -6
- package/{webpack.component.config.js → webpack/component.js} +1 -1
- package/{webpack.entry.config.js → webpack/entry.js} +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@variousjs/create",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "VariousJS boilerplate",
|
|
5
5
|
"bin": "bin/create.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"lint": "tsc --noemit && eslint . --ext .ts,.tsx,.js",
|
|
11
|
-
"start": "webpack --progress --config webpack
|
|
12
|
-
"build": "webpack --progress --config webpack
|
|
11
|
+
"start": "webpack --progress --config ./webpack/component.js & webpack serve --config ./webpack/entry.js --progress",
|
|
12
|
+
"build": "webpack --progress --config ./webpack/base.js",
|
|
13
13
|
"prepublishOnly": "node bin/copy.js"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"@babel/preset-typescript": "^7.15.0",
|
|
34
34
|
"@types/react": "^17.0.27",
|
|
35
35
|
"@types/react-dom": "^17.0.9",
|
|
36
|
-
"@types/react-router-dom": "^5.3.
|
|
36
|
+
"@types/react-router-dom": "^5.3.3",
|
|
37
37
|
"@typescript-eslint/eslint-plugin": "^4.31.2",
|
|
38
38
|
"@typescript-eslint/parser": "^4.31.2",
|
|
39
|
-
"@variousjs/various": "^0.
|
|
39
|
+
"@variousjs/various": "^0.5.0",
|
|
40
40
|
"babel-loader": "^8.2.2",
|
|
41
41
|
"css-loader": "^6.3.0",
|
|
42
42
|
"eslint": "^7.32.0",
|
|
@@ -51,6 +51,6 @@
|
|
|
51
51
|
"typescript": "^4.4.3",
|
|
52
52
|
"webpack": "^5.54.0",
|
|
53
53
|
"webpack-cli": "^4.8.0",
|
|
54
|
-
"webpack-dev-server": "^4.3
|
|
54
|
+
"webpack-dev-server": "^4.7.3"
|
|
55
55
|
}
|
|
56
56
|
}
|
package/package.json.copy
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"description": "VariousJS boilerplate",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "tsc --noemit && eslint . --ext .ts,.tsx,.js",
|
|
7
|
-
"start": "webpack --progress --config webpack
|
|
8
|
-
"build": "webpack --progress --config webpack
|
|
7
|
+
"start": "webpack --progress --config ./webpack/component.js & webpack serve --config ./webpack/entry.js --progress",
|
|
8
|
+
"build": "webpack --progress --config ./webpack/base.js"
|
|
9
9
|
},
|
|
10
10
|
"author": "LoeiFy <LoeiFy@gmail.com>",
|
|
11
11
|
"license": "MIT",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"@babel/preset-typescript": "^7.15.0",
|
|
17
17
|
"@types/react": "^17.0.27",
|
|
18
18
|
"@types/react-dom": "^17.0.9",
|
|
19
|
-
"@types/react-router-dom": "^5.3.
|
|
19
|
+
"@types/react-router-dom": "^5.3.3",
|
|
20
20
|
"@typescript-eslint/eslint-plugin": "^4.31.2",
|
|
21
21
|
"@typescript-eslint/parser": "^4.31.2",
|
|
22
|
-
"@variousjs/various": "^0.
|
|
22
|
+
"@variousjs/various": "^0.5.0",
|
|
23
23
|
"babel-loader": "^8.2.2",
|
|
24
24
|
"css-loader": "^6.3.0",
|
|
25
25
|
"eslint": "^7.32.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"typescript": "^4.4.3",
|
|
35
35
|
"webpack": "^5.54.0",
|
|
36
36
|
"webpack-cli": "^4.8.0",
|
|
37
|
-
"webpack-dev-server": "^4.3
|
|
37
|
+
"webpack-dev-server": "^4.7.3"
|
|
38
38
|
},
|
|
39
39
|
"private": true
|
|
40
40
|
}
|
package/src/components/card.tsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { FC } from 'react'
|
|
2
2
|
import { ComponentProps } from '@variousjs/various'
|
|
3
|
+
import { useParams } from 'react-router-dom'
|
|
3
4
|
import { Card, Button, message } from 'antd'
|
|
4
5
|
import csses from './card.less'
|
|
5
6
|
|
|
6
7
|
const H: FC<ComponentProps> & { getName: (e: string) => any } = (props) => {
|
|
7
|
-
const id =
|
|
8
|
+
const { id } = useParams<{ id: string }>()
|
|
8
9
|
|
|
9
10
|
return (
|
|
10
11
|
<div className={csses.container}>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { FC, useState, useEffect } from 'react'
|
|
2
|
+
import { ComponentProps } from '@variousjs/various'
|
|
3
|
+
import { useLocation, useHistory } from 'react-router-dom'
|
|
4
|
+
import { Radio, Badge, Button } from 'antd'
|
|
5
|
+
import { Config, Store } from '../types'
|
|
6
|
+
|
|
7
|
+
const H: FC<ComponentProps<Store, Config>> = (props) => {
|
|
8
|
+
const { pathname } = useLocation()
|
|
9
|
+
const history = useHistory()
|
|
10
|
+
const [path, setPath] = useState('')
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
setPath(pathname)
|
|
14
|
+
}, [])
|
|
15
|
+
|
|
16
|
+
const onRouterChange = (e: any) => {
|
|
17
|
+
history.push(e.target.value)
|
|
18
|
+
setPath(e.target.value)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<>
|
|
23
|
+
<Radio.Group
|
|
24
|
+
size="large"
|
|
25
|
+
value={path}
|
|
26
|
+
onChange={onRouterChange}
|
|
27
|
+
buttonStyle="solid"
|
|
28
|
+
>
|
|
29
|
+
{
|
|
30
|
+
props.$config.links.map(({ path, name }) => (
|
|
31
|
+
<Radio.Button key={path} value={path}>
|
|
32
|
+
{name}
|
|
33
|
+
</Radio.Button>
|
|
34
|
+
))
|
|
35
|
+
}
|
|
36
|
+
</Radio.Group>
|
|
37
|
+
<div>
|
|
38
|
+
Store:
|
|
39
|
+
<Badge
|
|
40
|
+
style={{ marginLeft: 10 }}
|
|
41
|
+
count={props.$store.user.name}
|
|
42
|
+
/>
|
|
43
|
+
<Button
|
|
44
|
+
style={{ marginLeft: 10 }}
|
|
45
|
+
onClick={() => props.$dispatch('card', 'getName', 'Card')}
|
|
46
|
+
>
|
|
47
|
+
Card Name
|
|
48
|
+
</Button>
|
|
49
|
+
</div>
|
|
50
|
+
</>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default H
|
package/src/entry/container.tsx
CHANGED
|
@@ -1,60 +1,20 @@
|
|
|
1
1
|
import React, { Component, ComponentType } from 'react'
|
|
2
|
-
import { ContainerProps
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { ContainerProps } from '@variousjs/various'
|
|
3
|
+
import { HashRouter as Router, Route } from 'react-router-dom'
|
|
4
|
+
import { Config } from '../types'
|
|
5
5
|
import csses from './entry.less'
|
|
6
6
|
|
|
7
|
-
class Container extends Component<ContainerProps<
|
|
8
|
-
state = {
|
|
9
|
-
path: '/'
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
onRouterChange = (e: any) => {
|
|
13
|
-
this.props.$router.history.push(e.target.value)
|
|
14
|
-
this.setState({ path: e.target.value })
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
componentDidMount() {
|
|
18
|
-
this.setState({ path: this.props.$router.location.pathname })
|
|
19
|
-
}
|
|
20
|
-
|
|
7
|
+
class Container extends Component<ContainerProps<Config>> {
|
|
21
8
|
render() {
|
|
22
|
-
const { $component, $config
|
|
9
|
+
const { $component, $config } = this.props
|
|
10
|
+
const Top = $component('top')
|
|
23
11
|
|
|
24
12
|
return (
|
|
25
13
|
<div className={csses.container}>
|
|
26
|
-
<div className={csses.top}>
|
|
27
|
-
<Radio.Group
|
|
28
|
-
size="large"
|
|
29
|
-
value={this.state.path}
|
|
30
|
-
onChange={this.onRouterChange}
|
|
31
|
-
buttonStyle="solid"
|
|
32
|
-
>
|
|
33
|
-
{
|
|
34
|
-
$config.links.map(({ path, name }) => (
|
|
35
|
-
<Radio.Button key={path} value={path}>
|
|
36
|
-
{name}
|
|
37
|
-
</Radio.Button>
|
|
38
|
-
))
|
|
39
|
-
}
|
|
40
|
-
</Radio.Group>
|
|
41
|
-
|
|
42
|
-
<div>
|
|
43
|
-
Store:
|
|
44
|
-
<Badge
|
|
45
|
-
style={{ marginLeft: 10 }}
|
|
46
|
-
count={$store.user.name}
|
|
47
|
-
/>
|
|
48
|
-
<Button
|
|
49
|
-
style={{ marginLeft: 10 }}
|
|
50
|
-
onClick={() => this.props.$dispatch('card', 'getName', 'Card')}
|
|
51
|
-
>
|
|
52
|
-
Card Name
|
|
53
|
-
</Button>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
|
|
57
14
|
<Router>
|
|
15
|
+
<div className={csses.top}>
|
|
16
|
+
<Top />
|
|
17
|
+
</div>
|
|
58
18
|
{
|
|
59
19
|
$config.pages.map(({ path, components }) => {
|
|
60
20
|
const cs = () => components.map((name) => {
|
|
@@ -3,14 +3,15 @@ const path = require('path')
|
|
|
3
3
|
const config = {
|
|
4
4
|
stats: 'minimal',
|
|
5
5
|
entry: {
|
|
6
|
-
entry: path.join(__dirname, '
|
|
6
|
+
entry: path.join(__dirname, '../src/entry'),
|
|
7
7
|
|
|
8
8
|
// 组件入口定义
|
|
9
|
-
card: path.join(__dirname, '
|
|
10
|
-
next: path.join(__dirname, '
|
|
9
|
+
card: path.join(__dirname, '../src/components/card.tsx'),
|
|
10
|
+
next: path.join(__dirname, '../src/components/next.tsx'),
|
|
11
|
+
top: path.join(__dirname, '../src/components/top.tsx'),
|
|
11
12
|
},
|
|
12
13
|
output: {
|
|
13
|
-
path: path.resolve(__dirname, '
|
|
14
|
+
path: path.resolve(__dirname, '../demo/dist'),
|
|
14
15
|
publicPath: '/dist/',
|
|
15
16
|
filename: '[name].js',
|
|
16
17
|
libraryTarget: 'amd',
|
|
@@ -26,6 +27,10 @@ const config = {
|
|
|
26
27
|
root: 'ReactDOM',
|
|
27
28
|
amd: 'react-dom',
|
|
28
29
|
},
|
|
30
|
+
'react-router-dom': {
|
|
31
|
+
root: 'ReactRouterDOM',
|
|
32
|
+
amd: 'react-router-dom',
|
|
33
|
+
},
|
|
29
34
|
'@variousjs/various': {
|
|
30
35
|
root: 'various',
|
|
31
36
|
amd: '@variousjs/various',
|
|
@@ -47,9 +52,8 @@ const config = {
|
|
|
47
52
|
allowedHosts: 'all',
|
|
48
53
|
port: 2333,
|
|
49
54
|
host: '0.0.0.0',
|
|
50
|
-
https: true,
|
|
51
55
|
static: {
|
|
52
|
-
directory: path.join(__dirname, '
|
|
56
|
+
directory: path.join(__dirname, '../demo'),
|
|
53
57
|
},
|
|
54
58
|
// 监听文件构建后重新刷新页面,包括 html 文件
|
|
55
59
|
watchFiles: ['demo'],
|