mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 23:52:06 +00:00
chore(examples): add tsx example (#4855)
This commit is contained in:
parent
774823ba41
commit
5101dc6aae
1
examples/typescript-tsx/README.md
Normal file
1
examples/typescript-tsx/README.md
Normal file
@ -0,0 +1 @@
|
||||
# TSX example
|
14
examples/typescript-tsx/components/HelloWorld/HelloWorld.tsx
Normal file
14
examples/typescript-tsx/components/HelloWorld/HelloWorld.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import Vue from 'vue'
|
||||
import styles from './styles.css'
|
||||
|
||||
export default Vue.extend({
|
||||
beforeCreate () {
|
||||
// Render Inline CSS on SSR
|
||||
if ((styles as any).__inject__) {
|
||||
(styles as any).__inject__(this.$ssrContext)
|
||||
}
|
||||
},
|
||||
render () {
|
||||
return <h1 class={styles.title}>Hello world!</h1>
|
||||
}
|
||||
})
|
3
examples/typescript-tsx/components/HelloWorld/index.ts
Normal file
3
examples/typescript-tsx/components/HelloWorld/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import HelloWorld from './HelloWorld'
|
||||
|
||||
export default HelloWorld
|
4
examples/typescript-tsx/components/HelloWorld/styles.css
Normal file
4
examples/typescript-tsx/components/HelloWorld/styles.css
Normal file
@ -0,0 +1,4 @@
|
||||
.title {
|
||||
font-style: italic;
|
||||
color: green;
|
||||
}
|
1
examples/typescript-tsx/components/HelloWorld/styles.css.d.ts
vendored
Normal file
1
examples/typescript-tsx/components/HelloWorld/styles.css.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export const title: string;
|
14
examples/typescript-tsx/nuxt.config.ts
Normal file
14
examples/typescript-tsx/nuxt.config.ts
Normal file
@ -0,0 +1,14 @@
|
||||
export default {
|
||||
build: {
|
||||
loaders: {
|
||||
vueStyle: {
|
||||
manualInject: true
|
||||
},
|
||||
css: {
|
||||
modules: true,
|
||||
importLoaders: 1,
|
||||
localIdentName: '[local]_[hash:base64:5]'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
22
examples/typescript-tsx/package.json
Normal file
22
examples/typescript-tsx/package.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "typescript-tsx",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"dev": "nuxt-ts",
|
||||
"build": "nuxt-ts build",
|
||||
"start": "nuxt-ts start",
|
||||
"generate": "nuxt-ts generate",
|
||||
"lint": "tslint --project .",
|
||||
"lint:fix": "tslint --project . --fix",
|
||||
"post-update": "yarn upgrade --latest",
|
||||
"watch:css": "tcm components -w"
|
||||
},
|
||||
"dependencies": {
|
||||
"nuxt-ts": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tslint-config-standard": "^8.0.1",
|
||||
"typed-css-modules": "^0.3.7"
|
||||
}
|
||||
}
|
13
examples/typescript-tsx/pages/index.tsx
Normal file
13
examples/typescript-tsx/pages/index.tsx
Normal file
@ -0,0 +1,13 @@
|
||||
import Vue from 'vue'
|
||||
import HelloWorld from '../components/HelloWorld'
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'Home',
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
<HelloWorld />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
})
|
11
examples/typescript-tsx/shims-tsx.d.ts
vendored
Normal file
11
examples/typescript-tsx/shims-tsx.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
import Vue, { VNode } from 'vue'
|
||||
|
||||
declare global {
|
||||
namespace JSX {
|
||||
interface Element extends VNode {}
|
||||
interface ElementClass extends Vue {}
|
||||
interface IntrinsicElements {
|
||||
[elem: string]: any
|
||||
}
|
||||
}
|
||||
}
|
8
examples/typescript-tsx/tsconfig.json
Normal file
8
examples/typescript-tsx/tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "@nuxt/typescript",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"noImplicitThis": true,
|
||||
"types": ["@types/node", "@nuxt/vue-app"]
|
||||
}
|
||||
}
|
7
examples/typescript-tsx/tslint.json
Normal file
7
examples/typescript-tsx/tslint.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"defaultSeverity": "error",
|
||||
"extends": ["tslint-config-standard"],
|
||||
"rules": {
|
||||
"prefer-const": true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user