Skip to content

Commit 6789283

Browse files
committed
chore: add config file for taro-ui and taro-ui-demo
1 parent 4cbbc72 commit 6789283

18 files changed

+209
-13
lines changed

packages/taro-ui-demo/.eslintrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
'extends': [
3+
// add more generic rulesets here, such as:
4+
// 'eslint:recommended',
5+
'taro/react'
6+
]
7+
}

packages/taro-ui-demo/babel.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// babel-preset-taro 更多选项和默认值:
2+
// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
3+
module.exports = {
4+
presets: [
5+
['taro', {
6+
framework: 'react',
7+
ts: true
8+
}]
9+
]
10+
}

packages/taro-ui-demo/config/dev.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
env: {
3+
NODE_ENV: '"development"'
4+
},
5+
defineConstants: {},
6+
weapp: {},
7+
h5: {}
8+
}

packages/taro-ui-demo/config/index.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
const config = {
2+
projectName: 'taro-ui-demo',
3+
date: '2020-4-5',
4+
designWidth: 750,
5+
deviceRatio: {
6+
640: 2.34 / 2,
7+
750: 1,
8+
828: 1.81 / 2
9+
},
10+
sourceRoot: 'src',
11+
outputRoot: 'dist',
12+
plugins: [],
13+
defineConstants: {},
14+
copy: {
15+
patterns: [],
16+
options: {}
17+
},
18+
framework: 'react',
19+
mini: {
20+
postcss: {
21+
pxtransform: {
22+
enable: true,
23+
config: {}
24+
},
25+
url: {
26+
enable: true,
27+
config: {
28+
limit: 1024 // 设定转换尺寸上限
29+
}
30+
},
31+
cssModules: {
32+
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
33+
config: {
34+
namingPattern: 'module', // 转换模式,取值为 global/module
35+
generateScopedName: '[name]__[local]___[hash:base64:5]'
36+
}
37+
}
38+
}
39+
},
40+
h5: {
41+
publicPath: '/',
42+
staticDirectory: 'static',
43+
postcss: {
44+
autoprefixer: {
45+
enable: true,
46+
config: {}
47+
},
48+
cssModules: {
49+
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
50+
config: {
51+
namingPattern: 'module', // 转换模式,取值为 global/module
52+
generateScopedName: '[name]__[local]___[hash:base64:5]'
53+
}
54+
}
55+
}
56+
}
57+
}
58+
59+
module.exports = function(merge) {
60+
if (process.env.NODE_ENV === 'development') {
61+
return merge({}, config, require('./dev'))
62+
}
63+
return merge({}, config, require('./prod'))
64+
}

packages/taro-ui-demo/config/prod.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
env: {
3+
NODE_ENV: '"production"'
4+
},
5+
defineConstants: {},
6+
weapp: {},
7+
h5: {
8+
/**
9+
* 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。
10+
* 参考代码如下:
11+
* webpackChain (chain) {
12+
* chain.plugin('analyzer')
13+
* .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
14+
* }
15+
*/
16+
}
17+
}

global.d.ts renamed to packages/taro-ui-demo/global.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,18 @@ declare module '*.less'
88
declare module '*.scss'
99
declare module '*.sass'
1010
declare module '*.styl'
11+
12+
declare const process: {
13+
env: {
14+
TARO_ENV:
15+
| 'weapp'
16+
| 'swan'
17+
| 'alipay'
18+
| 'h5'
19+
| 'rn'
20+
| 'tt'
21+
| 'quickapp'
22+
| 'qq'
23+
[key: string]: any
24+
}
25+
}

packages/taro-ui-demo/package.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"name": "taro-ui-demo",
3+
"version": "1.0.0",
4+
"private": true,
5+
"description": "Taro UI demo",
6+
"templateInfo": {
7+
"name": "default",
8+
"typescript": true,
9+
"css": "sass"
10+
},
11+
"scripts": {
12+
"build:weapp": "taro build --type weapp",
13+
"build:swan": "taro build --type swan",
14+
"build:alipay": "taro build --type alipay",
15+
"build:tt": "taro build --type tt",
16+
"build:h5": "taro build --type h5",
17+
"build:rn": "taro build --type rn",
18+
"build:qq": "taro build --type qq",
19+
"build:quickapp": "taro build --type quickapp",
20+
"dev:weapp": "npm run build:weapp -- --watch",
21+
"dev:swan": "npm run build:swan -- --watch",
22+
"dev:alipay": "npm run build:alipay -- --watch",
23+
"dev:tt": "npm run build:tt -- --watch",
24+
"dev:h5": "npm run build:h5 -- --watch",
25+
"dev:rn": "npm run build:rn -- --watch",
26+
"dev:qq": "npm run build:qq -- --watch",
27+
"dev:quickapp": "npm run build:quickapp -- --watch"
28+
},
29+
"browserslist": [
30+
"last 3 versions",
31+
"Android >= 4.1",
32+
"ios >= 8"
33+
],
34+
"author": "",
35+
"dependencies": {
36+
"@babel/runtime": "^7.7.7",
37+
"@tarojs/components": "3.0.0-beta.2",
38+
"@tarojs/runtime": "3.0.0-beta.2",
39+
"@tarojs/taro": "3.0.0-beta.2",
40+
"@tarojs/react": "3.0.0-beta.2",
41+
"react-dom": "^16.10.0",
42+
"react": "^16.10.0"
43+
},
44+
"devDependencies": {
45+
"@types/webpack-env": "^1.13.6",
46+
"@types/react": "^16.0.0",
47+
"@tarojs/mini-runner": "3.0.0-beta.2",
48+
"@babel/core": "^7.8.0",
49+
"@tarojs/webpack-runner": "3.0.0-beta.2",
50+
"babel-preset-taro": "3.0.0-beta.2",
51+
"eslint-config-taro": "3.0.0-beta.2",
52+
"eslint": "^6.8.0",
53+
"eslint-plugin-react": "^7.8.2",
54+
"eslint-plugin-import": "^2.12.0",
55+
"eslint-plugin-react-hooks": "^1.6.1",
56+
"stylelint": "9.3.0",
57+
"@typescript-eslint/parser": "^2.x",
58+
"@typescript-eslint/eslint-plugin": "^2.x",
59+
"typescript": "^3.7.0"
60+
}
61+
}

packages/taro-ui-demo/src/app.config.js renamed to packages/taro-ui-demo/src/app.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default {
5858
window: {
5959
backgroundTextStyle: 'light',
6060
navigationBarBackgroundColor: '#fff',
61-
navigationBarTitleText: 'WeChat',
61+
navigationBarTitleText: 'Taro UI',
6262
navigationBarTextStyle: 'black'
6363
}
6464
}

packages/taro-ui-demo/tsconfig.json

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
11
{
2-
"extends": "./config/tsconfig.base",
2+
"compileOnSave": false,
33
"compilerOptions": {
4-
"target": "es2017",
5-
"module": "commonjs",
4+
"allowJs": true,
5+
"allowSyntheticDefaultImports": true,
66
"baseUrl": ".",
7+
"experimentalDecorators": true,
8+
"jsx": "react",
9+
"jsxFactory": "React.createElement",
10+
"module": "commonjs",
11+
"moduleResolution": "node",
12+
"noImplicitAny": false,
13+
"noUnusedLocals": true,
14+
"noUnusedParameters": true,
15+
"outDir": "lib",
16+
"preserveConstEnums": true,
17+
"removeComments": false,
18+
"resolveJsonModule": true,
19+
"rootDir": ".",
20+
"sourceMap": true,
21+
"strictNullChecks": true,
22+
"target": "es2017",
723
"typeRoots": [
824
"node_modules/@types",
9-
"global.d.ts",
10-
"types"
11-
],
12-
"paths": {
13-
"taro-ui": [
14-
"src/index.ts"
15-
]
16-
}
17-
}
25+
"global.d.ts"
26+
]
27+
},
28+
"exclude": [
29+
"node_modules",
30+
"dist"
31+
]
1832
}

0 commit comments

Comments
 (0)