Skip to content

Commit 3dc0d74

Browse files
committed
feat: add rn
1 parent 471061b commit 3dc0d74

File tree

13 files changed

+3735
-319
lines changed

13 files changed

+3735
-319
lines changed

gulpfile.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ console.log(argvs, 'argvs')
2020
// 监视频率 https://www.martin-brennan.com/gulp-watch-high-cpu-usage/
2121
const interval = { interval: 500 }
2222
// 监视文件变化
23-
gulp.task('watch', function () {
23+
gulp.task('watch', () => {
2424
argvs.forEach((argv) => {
2525
gulp.watch(
2626
`src/packages/${argv}/demos/taro/*`,
@@ -42,6 +42,11 @@ gulp.task('watch', function () {
4242
interval,
4343
gulp.series(`${argv}copyTaro`)
4444
)
45+
gulp.watch(
46+
`src/packages/${argv}/${argv}.rn.tsx`,
47+
interval,
48+
gulp.series(`${argv}copyRN`)
49+
)
4550
})
4651
const watchTasks = []
4752
// eslint-disable-next-line array-callback-return
@@ -60,14 +65,14 @@ gulp.task('watch', function () {
6065
})
6166
argvs.forEach((argv) => {
6267
const targetBaseUrl = `${process.cwd()}/packages/nutui-taro-demo/nutui-react/packages/${argv}`
63-
gulp.task(`${argv}copyDemo`, function (path) {
68+
gulp.task(`${argv}copyDemo`, (path) => {
6469
console.log(path, 'path')
6570
return gulp
6671
.src(`src/packages/${argv}/demos/taro/*`)
6772
.pipe(gulp.dest(`${targetBaseUrl}/demos/taro/`))
6873
})
6974

70-
gulp.task(`${argv}sass`, function () {
75+
gulp.task(`${argv}sass`, () => {
7176
return gulp
7277
.src([`src/packages/${argv}/${argv}.scss`])
7378
.pipe(
@@ -94,7 +99,7 @@ argvs.forEach((argv) => {
9499
.pipe(gulp.dest(`src/packages/${argv}/`))
95100
})
96101

97-
gulp.task(`${argv}copyCss`, function () {
102+
gulp.task(`${argv}copyCss`, () => {
98103
return gulp
99104
.src([
100105
`src/packages/${argv}/*.scss`,
@@ -103,17 +108,23 @@ argvs.forEach((argv) => {
103108
.pipe(gulp.dest(`${targetBaseUrl}/`))
104109
})
105110

106-
gulp.task(`${argv}copyTaroDemo`, function () {
111+
gulp.task(`${argv}copyTaroDemo`, () => {
107112
return gulp
108113
.src(`src/packages/${argv}/demo.taro.tsx`)
109114
.pipe(insert.prepend(`import '../../../styles/demo.scss';\n`))
110115
.pipe(gulp.dest(`${targetBaseUrl}/`))
111116
})
112117

113-
gulp.task(`${argv}copyTaro`, function () {
118+
gulp.task(`${argv}copyTaro`, () => {
114119
return gulp
115120
.src(`src/packages/${argv}/${argv}.taro.tsx`)
116121
.pipe(insert.prepend(`import "./${argv}.harmony.css";\n`))
117122
.pipe(gulp.dest(`${targetBaseUrl}/`))
118123
})
124+
gulp.task(`${argv}copyRN`, () => {
125+
return gulp
126+
.src(`src/packages/${argv}/${argv}.rn.tsx`)
127+
.pipe(insert.prepend(`import "./${argv}.harmony.css";\n`))
128+
.pipe(gulp.dest(`${targetBaseUrl}/`))
129+
})
119130
})

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@
126126
"@rollup/plugin-node-resolve": "15.2.3",
127127
"@rollup/plugin-typescript": "^11.1.6",
128128
"@swc/core": "^1.4.8",
129-
"@tarojs/components": "^4.0.0-alpha.34",
130-
"@tarojs/plugin-platform-alipay": "^4.0.0-alpha.34",
131-
"@tarojs/plugin-platform-weapp": "^4.0.0-alpha.34",
132-
"@tarojs/react": "^4.0.0-alpha.34",
133-
"@tarojs/taro": "^4.0.0-alpha.34",
129+
"@tarojs/components": "4.0.2",
130+
"@tarojs/plugin-platform-alipay": "4.0.2",
131+
"@tarojs/plugin-platform-weapp": "4.0.2",
132+
"@tarojs/react": "4.0.2",
133+
"@tarojs/taro": "4.0.2",
134134
"@testing-library/jest-dom": "^6.4.2",
135135
"@testing-library/react": "^16.0.0",
136136
"@types/fs-extra": "^11.0.4",
@@ -194,6 +194,7 @@
194194
"react-color": "^2.19.3",
195195
"react-dom": "^18.2.0",
196196
"react-markdown": "^9.0.1",
197+
"react-native": "0.72.3",
197198
"react-refresh": "^0.14.0",
198199
"react-router-dom": "^6.22.1",
199200
"react-syntax-highlighter": "^15.5.0",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ const config = {
8585
'@/utils': path.resolve(__dirname, '../nutui-react/utils'),
8686
'@nutui/nutui-react-taro': path.resolve(
8787
__dirname,
88-
'../nutui-react/packages/nutui.react.taro.ts'
88+
'../nutui-react/packages/nutui.react.rn.ts'
8989
),
9090
'@nutui/icons-react-taro': path.resolve(
9191
__dirname,
92-
'../nutui-react/packages/nutui.react.taro.ts'
92+
'../nutui-react/packages/nutui.react.rn.ts'
9393
),
9494
'@styles': path.resolve(__dirname, '../styles'),
9595
}

packages/nutui-taro-demo/scripts/taro/generate-nutui-taro.js

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var glob = require('glob')
44
const path = require('path')
55
const fs = require('fs-extra')
66
let importStr = ``
7+
let importRNStr = ``
78
let importMarkdownStr = ``
89
let importScssStr = `\n`
910
const packages = []
@@ -12,14 +13,17 @@ const raws = []
1213

1314
config.nav.map((item) => {
1415
item.packages.forEach((element) => {
15-
let { name, show, type, taro, exportEmpty, exclude, version } = element
16+
let { name, show, type, taro, exportEmpty, exclude, version, rn } = element
1617
if (exclude) return
17-
if (version !== '3.0.0') return // 不显示的不导出
18+
if (version !== '3.0.0') return
1819

1920
importStr += `import ${name} from '@/packages/${name.toLowerCase()}/index.taro'\n`
2021
importStr += `export * from '@/packages/${name.toLowerCase()}/index.taro'\n`
22+
importRNStr += `import ${name} from '@/packages/${name.toLowerCase()}/index.${rn?'rn':'taro'}'\n`
23+
importRNStr += `export * from '@/packages/${name.toLowerCase()}/index.${rn?'rn':'taro'}'\n`
2124
importScssStr += `import '@/packages/${name.toLowerCase()}/${name.toLowerCase()}.harmony.css'\n`
2225
packages.push(name)
26+
2327
glob
2428
.sync(
2529
path.join(__dirname, `../../nutui-react/packages/${name.toLowerCase()}/`) +
@@ -41,18 +45,6 @@ config.nav.map((item) => {
4145
})
4246
})
4347

44-
// let fileStrBuild = `${importStr}
45-
// export { ${packages.join(',')} };`
46-
47-
// fs.outputFile(
48-
// path.resolve(__dirname, '../../nutui-react/packages/nutui.react.build.taro.ts'),
49-
// fileStrBuild,
50-
// 'utf8',
51-
// (error) => {
52-
// if (error) throw error
53-
// }
54-
// )
55-
5648
let fileStr = `${importStr}
5749
${importScssStr}
5850
export { ${packages.join(',')} };`
@@ -65,6 +57,18 @@ fs.outputFile(
6557
}
6658
)
6759

60+
let fileRNStr = `${importRNStr}
61+
${importScssStr}
62+
export { ${packages.join(',')} };`
63+
fs.outputFile(
64+
path.resolve(__dirname, '../../nutui-react/packages/nutui.react.rn.ts'),
65+
fileRNStr,
66+
'utf8',
67+
(error) => {
68+
if (error) throw error
69+
}
70+
)
71+
6872
let taroScssfileStr = `
6973
${importScssStr}
7074
export default { "NutUI":"NutUI-Taro" };`
@@ -76,28 +80,3 @@ fs.outputFile(
7680
if (error) throw error
7781
}
7882
)
79-
80-
// fs.outputFile(
81-
// path.resolve(__dirname, '../../nutui-react/packages/nutui.react.scss.ts'),
82-
// importScssStr,
83-
// 'utf8',
84-
// (error) => {
85-
// if (error) throw error
86-
// }
87-
// )
88-
89-
// let mdFileStr = `${importMarkdownStr}
90-
// export const routers = [${mds.map((m) => `'${m}'`)}]
91-
// export const raws = {${raws.join(',')}}
92-
// `
93-
94-
// fs.outputFile(
95-
// path.resolve(__dirname, '../../src/sites/doc/docs.taro.ts'),
96-
// mdFileStr,
97-
// 'utf8',
98-
// (error) => {
99-
// if (error) throw error
100-
// }
101-
// )
102-
103-

0 commit comments

Comments
 (0)