omip - init ts template
This commit is contained in:
parent
59222f8a3c
commit
94d7387b3b
|
@ -0,0 +1,12 @@
|
|||
# http://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"extends": ["taro"],
|
||||
"rules": {
|
||||
"no-unused-vars": ["error", { "varsIgnorePattern": "Taro" }],
|
||||
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".tsx"] }]
|
||||
},
|
||||
"parser": "babel-eslint",
|
||||
"plugins": ["typescript"]
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
dist/
|
||||
.temp/
|
||||
.rn_temp/
|
||||
node_modules/
|
||||
.DS_Store
|
|
@ -0,0 +1,9 @@
|
|||
module.exports = {
|
||||
env: {
|
||||
NODE_ENV: '"development"'
|
||||
},
|
||||
defineConstants: {
|
||||
},
|
||||
weapp: {},
|
||||
h5: {}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
const config = {
|
||||
projectName: 'my-app-ts',
|
||||
date: '2019-3-1',
|
||||
designWidth: 750,
|
||||
deviceRatio: {
|
||||
'640': 2.34 / 2,
|
||||
'750': 1,
|
||||
'828': 1.81 / 2
|
||||
},
|
||||
sourceRoot: 'src',
|
||||
outputRoot: 'dist',
|
||||
plugins: {
|
||||
babel: {
|
||||
sourceMap: true,
|
||||
presets: [
|
||||
['env', {
|
||||
modules: false
|
||||
}]
|
||||
],
|
||||
plugins: [
|
||||
'transform-decorators-legacy',
|
||||
'transform-class-properties',
|
||||
'transform-object-rest-spread'
|
||||
]
|
||||
}
|
||||
},
|
||||
defineConstants: {
|
||||
},
|
||||
copy: {
|
||||
patterns: [
|
||||
],
|
||||
options: {
|
||||
}
|
||||
},
|
||||
weapp: {
|
||||
module: {
|
||||
postcss: {
|
||||
autoprefixer: {
|
||||
enable: true,
|
||||
config: {
|
||||
browsers: [
|
||||
'last 3 versions',
|
||||
'Android >= 4.1',
|
||||
'ios >= 8'
|
||||
]
|
||||
}
|
||||
},
|
||||
pxtransform: {
|
||||
enable: true,
|
||||
config: {
|
||||
|
||||
}
|
||||
},
|
||||
url: {
|
||||
enable: true,
|
||||
config: {
|
||||
limit: 10240 // 设定转换尺寸上限
|
||||
}
|
||||
},
|
||||
cssModules: {
|
||||
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
|
||||
config: {
|
||||
namingPattern: 'module', // 转换模式,取值为 global/module
|
||||
generateScopedName: '[name]__[local]___[hash:base64:5]'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
h5: {
|
||||
publicPath: '/',
|
||||
staticDirectory: 'static',
|
||||
module: {
|
||||
postcss: {
|
||||
autoprefixer: {
|
||||
enable: true,
|
||||
config: {
|
||||
browsers: [
|
||||
'last 3 versions',
|
||||
'Android >= 4.1',
|
||||
'ios >= 8'
|
||||
]
|
||||
}
|
||||
},
|
||||
cssModules: {
|
||||
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
|
||||
config: {
|
||||
namingPattern: 'module', // 转换模式,取值为 global/module
|
||||
generateScopedName: '[name]__[local]___[hash:base64:5]'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function (merge) {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
return merge({}, config, require('./dev'))
|
||||
}
|
||||
return merge({}, config, require('./prod'))
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
module.exports = {
|
||||
env: {
|
||||
NODE_ENV: '"production"'
|
||||
},
|
||||
defineConstants: {
|
||||
},
|
||||
weapp: {},
|
||||
h5: {}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
declare module "*.png";
|
||||
declare module "*.gif";
|
||||
declare module "*.jpg";
|
||||
declare module "*.jpeg";
|
||||
declare module "*.svg";
|
||||
declare module "*.css";
|
||||
declare module "*.less";
|
||||
declare module "*.scss";
|
||||
declare module "*.sass";
|
||||
declare module "*.styl";
|
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"name": "my-app-ts",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"build:weapp": "taro build --type weapp",
|
||||
"build:swan": "taro build --type swan",
|
||||
"build:alipay": "taro build --type alipay",
|
||||
"build:tt": "taro build --type tt",
|
||||
"build:h5": "taro build --type h5",
|
||||
"build:rn": "taro build --type rn",
|
||||
"dev:weapp": "npm run build:weapp -- --watch",
|
||||
"dev:swan": "npm run build:swan -- --watch",
|
||||
"dev:alipay": "npm run build:alipay -- --watch",
|
||||
"dev:tt": "npm run build:tt -- --watch",
|
||||
"dev:h5": "npm run build:h5 -- --watch",
|
||||
"dev:rn": "npm run build:rn -- --watch"
|
||||
},
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tarojs/components": "1.2.15",
|
||||
"@tarojs/router": "1.2.15",
|
||||
"@tarojs/taro": "1.2.15",
|
||||
"@tarojs/taro-alipay": "1.2.15",
|
||||
"@tarojs/taro-h5": "1.2.15",
|
||||
"@tarojs/taro-swan": "1.2.15",
|
||||
"@tarojs/taro-tt": "1.2.15",
|
||||
"@tarojs/taro-weapp": "1.2.15",
|
||||
"nervjs": "^1.3.9",
|
||||
"nerv-devtools": "^1.3.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^16.4.6",
|
||||
"@types/webpack-env": "^1.13.6",
|
||||
"@tarojs/plugin-babel": "1.2.15",
|
||||
"@tarojs/plugin-csso": "1.2.15",
|
||||
"@tarojs/plugin-uglifyjs": "1.2.15",
|
||||
"@tarojs/webpack-runner": "1.2.15",
|
||||
"babel-plugin-transform-class-properties": "^6.24.1",
|
||||
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
||||
"babel-plugin-transform-jsx-stylesheet": "^0.6.5",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"babel-eslint": "^8.2.3",
|
||||
"eslint": "^4.19.1",
|
||||
"eslint-config-taro": "1.2.15",
|
||||
"eslint-plugin-react": "^7.8.2",
|
||||
"eslint-plugin-import": "^2.12.0",
|
||||
"eslint-plugin-taro": "1.2.15",
|
||||
"eslint-plugin-typescript": "^0.12.0",
|
||||
"typescript": "^3.0.1"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"miniprogramRoot": "./dist",
|
||||
"projectname": "my-app-ts",
|
||||
"description": "",
|
||||
"appid": "touristappid",
|
||||
"setting": {
|
||||
"urlCheck": true,
|
||||
"es6": false,
|
||||
"postcss": false,
|
||||
"minified": false
|
||||
},
|
||||
"compileType": "miniprogram"
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
import Taro, { Component, Config } from '@tarojs/taro'
|
||||
import Index from './pages/index'
|
||||
|
||||
import './app.css'
|
||||
|
||||
// 如果需要在 h5 环境中开启 React Devtools
|
||||
// 取消以下注释:
|
||||
// if (process.env.NODE_ENV !== 'production' && process.env.TARO_ENV === 'h5') {
|
||||
// require('nerv-devtools')
|
||||
// }
|
||||
|
||||
class App extends Component {
|
||||
|
||||
/**
|
||||
* 指定config的类型声明为: Taro.Config
|
||||
*
|
||||
* 由于 typescript 对于 object 类型推导只能推出 Key 的基本类型
|
||||
* 对于像 navigationBarTextStyle: 'black' 这样的推导出的类型是 string
|
||||
* 提示和声明 navigationBarTextStyle: 'black' | 'white' 类型冲突, 需要显示声明类型
|
||||
*/
|
||||
config: Config = {
|
||||
pages: [
|
||||
'pages/index/index'
|
||||
],
|
||||
window: {
|
||||
backgroundTextStyle: 'light',
|
||||
navigationBarBackgroundColor: '#fff',
|
||||
navigationBarTitleText: 'WeChat',
|
||||
navigationBarTextStyle: 'black'
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount () {}
|
||||
|
||||
componentDidShow () {}
|
||||
|
||||
componentDidHide () {}
|
||||
|
||||
componentDidCatchError () {}
|
||||
|
||||
// 在 App 类中的 render() 函数没有实际作用
|
||||
// 请勿修改此函数
|
||||
render () {
|
||||
return (
|
||||
<Index />
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Taro.render(<App />, document.getElementById('app'))
|
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<meta content="width=device-width,initial-scale=1,user-scalable=no" name="viewport">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-touch-fullscreen" content="yes">
|
||||
<meta name="format-detection" content="telephone=no,address=no">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="white">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >
|
||||
<title>Taro</title>
|
||||
<script>
|
||||
!function(x){function w(){var v,u,t,tes,s=x.document,r=s.documentElement,a=r.getBoundingClientRect().width;if(!v&&!u){var n=!!x.navigator.appVersion.match(/AppleWebKit.*Mobile.*/);v=x.devicePixelRatio;tes=x.devicePixelRatio;v=n?v:1,u=1/v}if(a>=640){r.style.fontSize="40px"}else{if(a<=320){r.style.fontSize="20px"}else{r.style.fontSize=a/320*20+"px"}}}x.addEventListener("resize",function(){w()});w()}(window);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,36 @@
|
|||
import Taro, { Component, Config } from '@tarojs/taro'
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import './index.css'
|
||||
|
||||
export default class Index extends Component {
|
||||
|
||||
/**
|
||||
* 指定config的类型声明为: Taro.Config
|
||||
*
|
||||
* 由于 typescript 对于 object 类型推导只能推出 Key 的基本类型
|
||||
* 对于像 navigationBarTextStyle: 'black' 这样的推导出的类型是 string
|
||||
* 提示和声明 navigationBarTextStyle: 'black' | 'white' 类型冲突, 需要显示声明类型
|
||||
*/
|
||||
config: Config = {
|
||||
navigationBarTitleText: '首页'
|
||||
}
|
||||
|
||||
componentWillMount () { }
|
||||
|
||||
componentDidMount () { }
|
||||
|
||||
componentWillUnmount () { }
|
||||
|
||||
componentDidShow () { }
|
||||
|
||||
componentDidHide () { }
|
||||
|
||||
render () {
|
||||
return (
|
||||
<View className='index'>
|
||||
<Text>Hello world!</Text>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2017",
|
||||
"module": "commonjs",
|
||||
"removeComments": false,
|
||||
"preserveConstEnums": true,
|
||||
"moduleResolution": "node",
|
||||
"experimentalDecorators": true,
|
||||
"noImplicitAny": false,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"outDir": "lib",
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"strictNullChecks": true,
|
||||
"sourceMap": true,
|
||||
"baseUrl": ".",
|
||||
"rootDir": ".",
|
||||
"jsx": "preserve",
|
||||
"jsxFactory": "Taro.createElement",
|
||||
"allowJs": true,
|
||||
"resolveJsonModule": true,
|
||||
"typeRoots": [
|
||||
"node_modules/@types",
|
||||
"global.d.ts"
|
||||
]
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist"
|
||||
],
|
||||
"compileOnSave": false
|
||||
}
|
Loading…
Reference in New Issue