-
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: plugin can use typescripts (#82)
* feat: plugin can use typescripts * fix: format
- Loading branch information
Showing
11 changed files
with
141 additions
and
18 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 |
---|---|---|
|
@@ -11,5 +11,5 @@ export default [ | |
minFile: false, | ||
}, | ||
}, | ||
<% } %> | ||
<% } -%> | ||
]; |
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,18 @@ | ||
|
||
export default [ | ||
{ | ||
cjs: 'babel', | ||
}, | ||
<% if (withUmiUI) { -%> | ||
{ | ||
entry: 'ui/index.tsx', | ||
typescriptOpts: { | ||
check: false, | ||
}, | ||
umd: { | ||
name: '<%= name %>', | ||
minFile: false, | ||
}, | ||
}, | ||
<% } -%> | ||
]; |
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 { join } from 'path'; | ||
import { IConfig } from 'umi-types'; | ||
|
||
export default { | ||
plugins: [ | ||
join(__dirname, '..', require('../package').main || 'index.js'), | ||
], | ||
} as IConfig; |
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,2 @@ | ||
declare module '*.css'; | ||
declare module '*.less'; |
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,9 @@ | ||
import styles from './index.css'; | ||
|
||
export default function() { | ||
return ( | ||
<div className={styles.normal}> | ||
<h1>Page index</h1> | ||
</div> | ||
); | ||
} |
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 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,23 @@ | ||
// ref: | ||
// - https://umijs.org/plugin/develop.html | ||
import { IApi } from 'umi-types'; | ||
|
||
export default function (api: IApi, options) { | ||
|
||
// Example: output the webpack config | ||
api.chainWebpackConfig(config => { | ||
console.log(config.toString()); | ||
}); | ||
|
||
<% if (withUmiUI) { -%> | ||
api.addUIPlugin(require.resolve('../dist/index.umd')); | ||
|
||
api.onUISocket(({ action, failure, success }) => { | ||
if (action.type === 'org.<%= author %>.<%= name %>.test') { | ||
success({ | ||
data: '<%= name %>.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,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "esnext", | ||
"target": "esnext", | ||
"lib": ["esnext", "dom"], | ||
"sourceMap": true, | ||
"baseUrl": ".", | ||
"jsx": "react", | ||
"allowSyntheticDefaultImports": true, | ||
"moduleResolution": "node", | ||
"forceConsistentCasingInFileNames": true, | ||
"noImplicitReturns": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"noUnusedLocals": true, | ||
"experimentalDecorators": true, | ||
"declaration": false | ||
} | ||
} |
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,29 @@ | ||
import { Button } from 'antd'; | ||
import { IUiApi } from 'umi-types' | ||
|
||
export default (api: IUiApi) => { | ||
const { callRemote } = api; | ||
|
||
function PluginPanel() { | ||
return ( | ||
<div style={{ padding: 20 }}> | ||
<Button | ||
type="primary" | ||
onClick={async () => { | ||
const { data } = await callRemote({ | ||
type: 'org.<%= author %>.<%= name %>.test', | ||
}); | ||
alert(data); | ||
}} | ||
>Test</Button> | ||
</div> | ||
); | ||
} | ||
|
||
api.addPanel({ | ||
title: '<%= name %>', | ||
path: '/<%= name %>', | ||
icon: 'home', | ||
component: PluginPanel, | ||
}); | ||
} |