-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create plugin Upgrade to Umi 3 (#107)
create plugin Upgrade to Umi 3 (#107)
- Loading branch information
Showing
38 changed files
with
412 additions
and
167 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[Makefile] | ||
indent_style = tab |
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,15 +1,35 @@ | ||
<% if (withUmiUI) { -%> | ||
const isProd = process.env.NODE_ENV === 'prod'; | ||
|
||
export default [ | ||
{ | ||
cjs: 'babel', | ||
}, | ||
<% } -%> | ||
export default [{ | ||
target: 'node', | ||
cjs: { type: 'babel', lazy: true }, | ||
disableTypeCheck: true, | ||
extraBabelPlugins: [ | ||
[ | ||
'babel-plugin-import', | ||
{ libraryName: 'antd', libraryDirectory: 'es', style: true }, | ||
'antd', | ||
], | ||
], | ||
<% if (withUmiUI) { -%> | ||
{ | ||
entry: 'ui/index.js', | ||
umd: { | ||
name: '<%= name %>', | ||
minFile: false, | ||
}, | ||
{ | ||
entry: 'ui/index.tsx', | ||
umd: { | ||
name: 'tasks', | ||
minFile: isProd, | ||
sourcemap: !isProd, | ||
}, | ||
extraExternals: ['antd', 'react', 'react-dom', 'xterm'], | ||
typescriptOpts: { | ||
check: false, | ||
globals: { | ||
antd: 'window.antd', | ||
react: 'window.React', | ||
'react-dom': 'window.ReactDOM', | ||
}, | ||
}, | ||
<% } -%> | ||
]; | ||
}]; |
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,18 +1,35 @@ | ||
<% if (withUmiUI) { -%> | ||
const isProd = process.env.NODE_ENV === 'prod'; | ||
|
||
export default [ | ||
{ | ||
cjs: 'babel', | ||
}, | ||
<% } -%> | ||
export default [{ | ||
target: 'node', | ||
cjs: { type: 'babel', lazy: true }, | ||
disableTypeCheck: true, | ||
extraBabelPlugins: [ | ||
[ | ||
'babel-plugin-import', | ||
{ libraryName: 'antd', libraryDirectory: 'es', style: true }, | ||
'antd', | ||
], | ||
], | ||
<% if (withUmiUI) { -%> | ||
{ | ||
entry: 'ui/index.tsx', | ||
typescriptOpts: { | ||
check: false, | ||
}, | ||
umd: { | ||
name: '<%= name %>', | ||
minFile: false, | ||
}, | ||
{ | ||
entry: 'ui/index.tsx', | ||
umd: { | ||
name: 'tasks', | ||
minFile: isProd, | ||
sourcemap: !isProd, | ||
}, | ||
extraExternals: ['antd', 'react', 'react-dom', 'xterm'], | ||
typescriptOpts: { | ||
check: false, | ||
globals: { | ||
antd: 'window.antd', | ||
react: 'window.React', | ||
'react-dom': 'window.ReactDOM', | ||
}, | ||
}, | ||
<% } -%> | ||
]; | ||
}]; |
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,8 @@ | ||
node_modules | ||
.changelog | ||
.umi | ||
.umi-test | ||
.umi-production | ||
.DS_Store | ||
/lib | ||
dist |
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,8 @@ | ||
**/node_modules/** | ||
package.json | ||
|
||
# fixtures | ||
**/fixtures/** | ||
|
||
# templates | ||
**/templates/** |
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,14 @@ | ||
{ | ||
"printWidth": 80, | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"proseWrap": "never", | ||
"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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Contributing to plugin | ||
|
||
## Set up | ||
|
||
Install dev deps after git clone the repo. | ||
|
||
```bash | ||
# npm is not allowed. | ||
$ yarn | ||
``` | ||
|
||
## Build | ||
|
||
Transform with babel and rollup. | ||
|
||
```bash | ||
$ yarn build | ||
|
||
# Build and monitor file changes | ||
$ yarn build --watch | ||
|
||
``` | ||
|
||
## Dev Plugin | ||
|
||
```bash | ||
# This Step must only be executed in Build | ||
$ yarn dev | ||
``` | ||
|
||
## Debug | ||
|
||
TODO | ||
|
||
## Test | ||
|
||
```bash | ||
$ yarn test | ||
``` | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/.umi | ||
/.umi-production | ||
/dist | ||
/node_modules | ||
/yarn.lock |
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,10 +1,8 @@ | ||
import { join } from 'path'; | ||
import { defineConfig } from 'umi'; | ||
|
||
export default { | ||
routes: [ | ||
{ path: '/', component: './index' }, | ||
], | ||
plugins: [ | ||
join(__dirname, '..', require('../package').main || 'index.js'), | ||
], | ||
} | ||
export default defineConfig({ | ||
<% if (withUmiUI) { -%> | ||
presets: [require.resolve('@umijs/preset-ui')], | ||
<% } -%> | ||
plugins: [require.resolve('../lib')], | ||
}); |
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,11 +1,8 @@ | ||
import { join } from 'path'; | ||
import { IConfig } from 'umi-types'; | ||
import { defineConfig } from 'umi'; | ||
|
||
export default { | ||
routes: [ | ||
{ path: '/', component: './index' }, | ||
], | ||
plugins: [ | ||
join(__dirname, '..', require('../package').main || 'index.js'), | ||
], | ||
} as IConfig; | ||
export default defineConfig({ | ||
<% if (withUmiUI) { -%> | ||
presets: [require.resolve('@umijs/preset-ui')], | ||
<% } -%> | ||
plugins: [require.resolve('../lib')], | ||
}); |
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 @@ | ||
export function render(oldRender) { | ||
oldRender(); | ||
} |
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 @@ | ||
export function render(oldRender: Function) { | ||
oldRender(); | ||
} |
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 +1,3 @@ | ||
{} | ||
{ | ||
"dependencies": {} | ||
} |
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,4 +1,17 @@ | ||
body, | ||
html, | ||
#root { | ||
height: 100%; | ||
margin: 0; | ||
} | ||
|
||
a { | ||
color: #1890ff; | ||
cursor: pointer; | ||
} | ||
|
||
.normal { | ||
background: #79F2AA; | ||
background: #ddd; | ||
height: 100vh; | ||
padding: 48px; | ||
} |
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,8 @@ | ||
import React from 'react'; | ||
import styles from './index.css'; | ||
|
||
export default () => ( | ||
<div className={styles.normal}> | ||
Hello Umi! | ||
</div> | ||
); |
12 changes: 5 additions & 7 deletions
12
lib/generators/plugin/templates/example/pages/index.tsx
100755 → 100644
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,10 +1,8 @@ | ||
import React from 'react'; | ||
import styles from './index.css'; | ||
|
||
export default function() { | ||
return ( | ||
<div className={styles.normal}> | ||
<h1>Page index</h1> | ||
</div> | ||
); | ||
} | ||
export default () => ( | ||
<div className={styles.normal}> | ||
Hello Umi! | ||
</div> | ||
); |
Oops, something went wrong.