-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
copy umijs example from vercel/vercel (#1038)
- Loading branch information
1 parent
cd1f11d
commit 1a1b2f0
Showing
21 changed files
with
17,325 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/npm-debug.log* | ||
/yarn-error.log | ||
/package-lock.json | ||
|
||
# production | ||
/dist | ||
|
||
# misc | ||
.DS_Store | ||
|
||
# umi | ||
.umi | ||
.umi-production | ||
|
||
# environment variables | ||
.env | ||
.env.build | ||
|
||
.vercel |
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,7 @@ | ||
**/*.md | ||
**/*.svg | ||
**/*.ejs | ||
**/*.html | ||
package.json | ||
.umi | ||
.umi-production |
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": 100, | ||
"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,25 @@ | ||
import { IConfig } from 'umi-types'; | ||
|
||
// ref: https://umijs.org/config/ | ||
const config: IConfig = { | ||
treeShaking: true, | ||
plugins: [ | ||
// ref: https://umijs.org/plugin/umi-plugin-react.html | ||
[ | ||
'umi-plugin-react', | ||
{ | ||
antd: false, | ||
dva: false, | ||
dynamicImport: false, | ||
title: 'umijs', | ||
dll: false, | ||
|
||
routes: { | ||
exclude: [/components\//], | ||
}, | ||
}, | ||
], | ||
], | ||
}; | ||
|
||
export default config; |
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 @@ | ||
README.md |
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,21 @@ | ||
![UmiJS Logo](https://github.com/vercel/vercel/blob/main/packages/frameworks/logos/umi.svg) | ||
|
||
# UmiJS Example | ||
|
||
This directory is a brief example of a [UmiJS](https://umijs.org/) app that can be deployed to Vercel with zero configuration. | ||
|
||
## Deploy Your Own | ||
|
||
Deploy your own UmiJS project with Vercel. | ||
|
||
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vercel/examples/tree/main/framework-boilerplates/umijs&template=umijs) | ||
|
||
_Live Example: https://umijs-template.vercel.app_ | ||
|
||
### How We Created This Example | ||
|
||
To get started with UmiJS deployed with Vercel, you can use the [Umi CLI](https://github.com/umijs/create-umi) to initialize the project: | ||
|
||
```shell | ||
$ yarn create umi app-name | ||
``` |
Empty file.
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,51 @@ | ||
{ | ||
"private": true, | ||
"scripts": { | ||
"start": "umi dev", | ||
"dev": "umi dev --port $PORT", | ||
"build": "umi build", | ||
"test": "umi test", | ||
"lint:es": "eslint --ext .js src mock tests", | ||
"lint:ts": "tslint \"src/**/*.ts\" \"src/**/*.tsx\"", | ||
"precommit": "lint-staged" | ||
}, | ||
"dependencies": { | ||
"react": "^16.8.6", | ||
"react-dom": "^16.8.6" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^23.3.12", | ||
"@types/react": "^16.7.18", | ||
"@types/react-dom": "^16.0.11", | ||
"@types/react-test-renderer": "^16.0.3", | ||
"babel-eslint": "^9.0.0", | ||
"eslint": "^5.4.0", | ||
"eslint-config-umi": "^1.4.0", | ||
"eslint-plugin-flowtype": "^2.50.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-jsx-a11y": "^5.1.1", | ||
"eslint-plugin-react": "^7.11.1", | ||
"husky": "^0.14.3", | ||
"lint-staged": "^7.2.2", | ||
"react-test-renderer": "^16.7.0", | ||
"tslint": "^5.12.0", | ||
"tslint-eslint-rules": "^5.4.0", | ||
"tslint-react": "^3.6.0", | ||
"umi": "^2.7.0", | ||
"umi-plugin-react": "^1.8.0", | ||
"umi-types": "^0.2.0" | ||
}, | ||
"lint-staged": { | ||
"*.{ts,tsx}": [ | ||
"tslint --fix", | ||
"git add" | ||
], | ||
"*.{js,jsx}": [ | ||
"eslint --fix", | ||
"git add" | ||
] | ||
}, | ||
"engines": { | ||
"node": "16.x" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
|
||
html, body, #root { | ||
height: 100%; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
} |
16 changes: 16 additions & 0 deletions
16
framework-boilerplates/umijs/src/layouts/__tests__/index.test.tsx
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 @@ | ||
import 'jest'; | ||
import BasicLayout from '..'; | ||
import React from 'react'; | ||
import renderer, { ReactTestInstance, ReactTestRenderer } from 'react-test-renderer'; | ||
|
||
describe('Layout: BasicLayout', () => { | ||
it('Render correctly', () => { | ||
const wrapper: ReactTestRenderer = renderer.create(<BasicLayout />); | ||
expect(wrapper.root.children.length).toBe(1); | ||
const outerLayer = wrapper.root.children[0] as ReactTestInstance; | ||
expect(outerLayer.type).toBe('div'); | ||
const title = outerLayer.children[0] as ReactTestInstance; | ||
expect(title.type).toBe('h1'); | ||
expect(title.children[0]).toBe('Yay! Welcome to umi!'); | ||
}); | ||
}); |
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,15 @@ | ||
|
||
.normal { | ||
font-family: Georgia, sans-serif; | ||
text-align: center; | ||
} | ||
|
||
.title { | ||
font-size: 2.5rem; | ||
font-weight: normal; | ||
letter-spacing: -1px; | ||
background: darkslateblue; | ||
padding: .6em 0; | ||
color: white; | ||
margin: 0; | ||
} |
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,13 @@ | ||
import React from 'react'; | ||
import styles from './index.css'; | ||
|
||
const BasicLayout: React.FC = props => { | ||
return ( | ||
<div className={styles.normal}> | ||
<h1 className={styles.title}>Yay! Welcome to umi!</h1> | ||
{props.children} | ||
</div> | ||
); | ||
}; | ||
|
||
export default BasicLayout; |
16 changes: 16 additions & 0 deletions
16
framework-boilerplates/umijs/src/pages/__tests__/index.test.tsx
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 @@ | ||
import 'jest'; | ||
import Index from '..'; | ||
import React from 'react'; | ||
import renderer, { ReactTestInstance, ReactTestRenderer } from 'react-test-renderer'; | ||
|
||
|
||
describe('Page: index', () => { | ||
it('Render correctly', () => { | ||
const wrapper: ReactTestRenderer = renderer.create(<Index />); | ||
expect(wrapper.root.children.length).toBe(1); | ||
const outerLayer = wrapper.root.children[0] as ReactTestInstance; | ||
expect(outerLayer.type).toBe('div'); | ||
expect(outerLayer.children.length).toBe(2); | ||
|
||
}); | ||
}); |
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 @@ | ||
|
||
.normal { | ||
font-family: Georgia, sans-serif; | ||
margin-top: 4em; | ||
text-align: center; | ||
} | ||
|
||
.welcome { | ||
height: 328px; | ||
background: url(../assets/yay.jpg) no-repeat center 0; | ||
background-size: 388px 328px; | ||
} | ||
|
||
.list { | ||
font-size: 1.2em; | ||
margin-top: 1.8em; | ||
list-style: none; | ||
line-height: 1.5em; | ||
} | ||
|
||
.list code { | ||
background: #f7f7f7; | ||
} |
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,19 @@ | ||
import React from 'react'; | ||
import styles from './index.css'; | ||
|
||
|
||
export default function() { | ||
return ( | ||
<div className={styles.normal}> | ||
<div className={styles.welcome} /> | ||
<ul className={styles.list}> | ||
<li>To get started, edit <code>src/pages/index.js</code> and save to reload.</li> | ||
<li> | ||
<a href="https://umijs.org/guide/getting-started.html"> | ||
Getting Started | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
); | ||
} |
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,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "esnext", | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"importHelpers": true, | ||
"jsx": "react", | ||
"esModuleInterop": true, | ||
"sourceMap": true, | ||
"baseUrl": ".", | ||
"strict": true, | ||
"paths": { | ||
"@/*": ["src/*"] | ||
}, | ||
"allowSyntheticDefaultImports": true | ||
} | ||
} |
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 @@ | ||
defaultSeverity: error | ||
extends: | ||
- tslint-react | ||
- tslint-eslint-rules | ||
jsRules: | ||
rules: | ||
eofline: true | ||
no-console: true | ||
no-construct: true | ||
no-debugger: true | ||
no-reference: true |
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 '*.png'; |
Oops, something went wrong.