Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,42 @@ const postcss = require('gulp-postcss')
const rename = require('gulp-rename')
const cssvariables = require('postcss-css-variables')
const insert = require('gulp-insert')
const config = require('./src/config.json')

const argvs = process.argv.splice(4)[0]?.split('/') || []

const adaptedNameArray = []
// eslint-disable-next-line array-callback-return
config.nav.map((item) => {
item.packages.forEach((element) => {
const { name, version } = element
if (version !== '3.0.0') return // 未适配不导出
adaptedNameArray.push(name.toLowerCase())
})
})
const argvs = process.argv.splice(4)[0]?.split('/') || adaptedNameArray
console.log(argvs, 'argvs')

// 监视频率 https://www.martin-brennan.com/gulp-watch-high-cpu-usage/
const interval = { interval: 500 }
// 监视文件变化
gulp.task('watch', function () {
argvs.forEach((argv) => {
gulp.watch(
`src/packages/${argv}/demos/taro/*`,
interval,
gulp.series(`${argv}copyDemo`)
)
gulp.watch(
`src/packages/${argv}/*.scss`,
interval,
gulp.series(`${argv}sass`, `${argv}copyCss`)
)
gulp.watch(
`src/packages/${argv}/demo.taro.tsx`,
interval,
gulp.series(`${argv}copyTaroDemo`)
)
gulp.watch(
`src/packages/${argv}/${argv}.taro.tsx`,
interval,
gulp.series(`${argv}copyTaro`)
)
})
Expand All @@ -33,13 +48,13 @@ gulp.task('watch', function () {
argvs.map((argv) => {
watchTasks.push(...[`${argv}sass`, `${argv}copyCss`])
})
console.log(watchTasks.join(','), 'watchTasks')
gulp.watch(
[
`src/styles/variables.scss`,
'src/styles/mixins/text-ellipsis.scss',
'src/styles/theme-default.scss',
],
interval,
gulp.series(watchTasks)
)
})
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@
"dev:taro:alipay": "pnpm --dir ./packages/nutui-taro-demo dev:alipay",
"dev:taro:harmony": "pnpm --dir ./packages/nutui-taro-demo dev:harmony",
"dev:taro:jdharmony": "pnpm --dir ./packages/nutui-taro-demo dev:jdharmony",
"dev:taro:jdhybrid": "pnpm --dir ./packages/nutui-taro-demo-rn dev:jdhybrid",
"rn:copy": "node ./scripts/rn/copy-file.js",
"dev:taro:rn": "pnpm --dir ./packages/nutui-taro-demo-rn dev:jdrn & pnpm run gulp:watch",
"dev:taro:jdrn": "pnpm run rn:copy && pnpm --dir ./packages/nutui-taro-demo-rn dev:jdrn & pnpm run gulp:watch",
"dev:taro:rn:dark": "THEME=dark pnpm dev:taro:rn",
"gulp:watch": "gulp watch --environment",
"dev:taro:weapp:jmapp": "pnpm --dir ./packages/nutui-taro-demo && npm run dev:weapp:jmapp",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@
"dentry/pages/form/index",
"dentry/pages/input/index",
"dentry/pages/inputnumber/index",
"dentry1/pages/menu/index",
"dentry1/pages/numberkeyboard/index",
"dentry1/pages/picker/index",
"dentry1/pages/radio/index",
"dentry1/pages/range/index",
"dentry1/pages/rate/index",
"dentry1/pages/searchbar/index",
"dentry1/pages/shortpassword/index",
"dentry1/pages/signature/index",
"dentry1/pages/switch/index",
"dentry1/pages/textarea/index",
"dentry1/pages/uploader/index",
"dataentry/pages/menu/index",
"dataentry/pages/numberkeyboard/index",
"dataentry/pages/picker/index",
"dataentry/pages/radio/index",
"dataentry/pages/range/index",
"dataentry/pages/rate/index",
"dataentry/pages/searchbar/index",
"dataentry/pages/shortpassword/index",
"dataentry/pages/signature/index",
"dataentry/pages/switch/index",
"dataentry/pages/textarea/index",
"dataentry/pages/uploader/index",
"feedback/pages/actionsheet/index",
"feedback/pages/badge/index",
"feedback/pages/dialog/index",
Expand All @@ -54,10 +54,10 @@
"feedback/pages/popover/index",
"feedback/pages/popup/index",
"feedback/pages/pulltorefresh/index",
"feedback/pages/resultpage/index",
"feedback/pages/skeleton/index",
"feedback/pages/swipe/index",
"feedback/pages/toast/index",
"feedback/pages/resultpage/index",
"exhibition/pages/animate/index",
"exhibition/pages/animatingnumbers/index",
"exhibition/pages/avatar/index",
Expand Down
7 changes: 4 additions & 3 deletions packages/nutui-taro-demo-rn/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module.exports = {
},
],
],
plugins: [
// ['@babel/plugin-transform-typescript', { allowDeclareFields: true }],
],
plugins:
process.env.TARO_ENV === 'rn' || process.env.TARO_ENV === 'jdrn'
? []
: [['@babel/plugin-transform-typescript', { allowDeclareFields: true }]],
}
2 changes: 2 additions & 0 deletions packages/nutui-taro-demo-rn/config/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module.exports = {
maxInitialRequests: Infinity,
minSize: 0,
cacheGroups: {
default: false,
defaultVendors: false,
common: {
name: 'common',
minChunks: 2,
Expand Down
133 changes: 91 additions & 42 deletions packages/nutui-taro-demo-rn/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,49 @@ if (projectID) {
fileStr = `src/styles/variables-${projectID}.scss`
themeStr = `src/styles/theme-${projectID}.scss`
}
const sassResource = [
path.resolve(__dirname, '../../../', fileStr),
path.resolve(__dirname, '../../../', themeStr),
]
const theme = process.env.THEME
if (theme) {
sassResource.push(
path.resolve(__dirname, '../../../', `src/styles/theme-${theme}.scss`)
)

let plugins = !['harmony', 'jdharmony', 'rn', 'jdrn'].includes(
process.env.TARO_ENV
)
? ['@tarojs/plugin-html']
: []

if (
process.env.TARO_ENV === 'harmony' ||
process.env.TARO_ENV === 'jdharmony'
) {
plugins.push('@tarojs/plugin-platform-harmony-ets')
plugins.push('@tarojs/taro-platform-jdharmony')
}

if (process.env.TARO_ENV === 'rn' || process.env.TARO_ENV === 'jdrn') {
plugins.push('@jdtaro/plugin-platform-jdrn')
}

// 小程序、jd H5 通过此插件覆盖
if (
process.env.TARO_ENV === 'weapp' ||
process.env.TARO_ENV === 'jd' ||
process.env.TARO_ENV === 'jdhybrid'
) {
plugins.push('@dongdesign/inject-jd-platform-styles')
}

if (process.env.TARO_ENV === 'jdhybrid') {
plugins.push([
'@jdtaro/plugin-platform-jdhybrid',
{
externals: {
'@jdtaro/plugin-platform-jdhybrid': 'local',
},
},
])
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
// if (process.env.TARO_ENV === 'jdharmony') {
// plugins = ['@test/taro-platform-jdharmony']
// }

const config = {
projectName: 'first',
Expand All @@ -30,39 +63,49 @@ const config = {
375: 2 / 1,
},
sourceRoot: 'src',
outputRoot: `dist/${
process.env.TARO_ENV === 'h5' ? 'demo' : process.env.TARO_ENV
}`,
plugins: [
path.resolve(__dirname, '../plugins/inject-scss.js'),
process.env.TARO_ENV === 'harmony'
? '@tarojs/plugin-platform-harmony-ets'
: process.env.TARO_ENV === 'jdrn'
? '@jdtaro/plugin-platform-jdrn'
: '@tarojs/plugin-html',
],
outputRoot: `dist/${process.env.TARO_ENV === 'h5' ? 'demo' : process.env.TARO_ENV}`,
plugins: [path.resolve(__dirname, '../plugins/inject-scss.js'), ...plugins],
compiler: 'webpack5',
alias: {
'@nutui/nutui-react-taro/dist/locales/en-US': path.resolve(
__dirname,
'../nutui-react/locales/en-US.ts'
),
'@/packages': path.resolve(__dirname, '../nutui-react/packages'),
'@/sites': path.resolve(__dirname, '../nutui-react/sites'),
'@/locales': path.resolve(__dirname, '../nutui-react/locales'),
'@/utils': path.resolve(__dirname, '../nutui-react/utils'),
'@nutui/nutui-react-taro': path.resolve(
__dirname,
'../nutui-react/packages/nutui.react.taro.ts'
),
'@nutui/icons-react-taro': path.resolve(
__dirname,
'../nutui-react/packages/nutui.react.taro.ts'
),
'@styles': path.resolve(__dirname, '../styles'),
},
alias:
process.env.TARO_ENV === 'rn' || process.env.TARO_ENV === 'jdrn'
? {
'@nutui/nutui-react-taro/dist/locales/en-US': path.resolve(
__dirname,
'../nutui-react/locales/en-US.ts'
),
'@/packages': path.resolve(__dirname, '../nutui-react/packages'),
'@/sites': path.resolve(__dirname, '../nutui-react/sites'),
'@/locales': path.resolve(__dirname, '../nutui-react/locales'),
'@/utils': path.resolve(__dirname, '../nutui-react/utils'),
'@nutui/nutui-react-taro': path.resolve(
__dirname,
'../nutui-react/packages/nutui.react.taro.ts'
),
'@nutui/icons-react-taro': path.resolve(
__dirname,
'../nutui-react/packages/nutui.react.taro.ts'
),
'@styles': path.resolve(__dirname, '../styles'),
}
: {
'@nutui/nutui-react-taro/dist/locales/en-US': path.resolve(
__dirname,
'../../../src/locales/en-US.ts'
),
'@/packages': path.resolve(__dirname, '../../../src/packages'),
'@/sites': path.resolve(__dirname, '../../../src/sites'),
'@/locales': path.resolve(__dirname, '../../../src/locales'),
'@/utils': path.resolve(__dirname, '../../../src/utils'),
'@nutui/nutui-react-taro': path.resolve(
__dirname,
'../../../src/packages/nutui.react.taro.ts'
),
},
sass: {
resource: sassResource,
resource: [
path.resolve(__dirname, '../../../', fileStr),
path.resolve(__dirname, '../../../', themeStr),
],
},
defineConstants: {},
copy: {
Expand Down Expand Up @@ -103,6 +146,9 @@ const config = {
},
},
mini: {
compile: {
include: [path.resolve(__dirname, '../../../src')],
},
postcss: {
pxtransform: {
enable: true,
Expand All @@ -125,6 +171,9 @@ const config = {
},
},
h5: {
compile: {
include: [path.resolve(__dirname, '../../../src')],
},
publicPath: '/',
staticDirectory: 'static',
postcss: {
Expand Down Expand Up @@ -177,7 +226,7 @@ const config = {

module.exports = function (merge) {
if (process.env.NODE_ENV === 'development') {
return Object.assign({}, config, require('./dev'))
return merge({}, config, require('./dev'))
}
return Object.assign({}, config, require('./prod'))
return merge({}, config, require('./prod'))
}
11 changes: 7 additions & 4 deletions packages/nutui-taro-demo-rn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"build:jd": "taro build --type jd",
"build:quickapp": "taro build --type quickapp",
"build:harmony": "taro build --type harmony",
"build:jdhybrid": "taro build --type jdhybrid",
"dev:harmony": "npm run build:harmony -- --watch",
"dev:jdharmony": "pnpm exec taro build native-components --type jdharmony",
"dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch",
Expand All @@ -29,6 +31,7 @@
"dev:qq": "npm run build:qq -- --watch",
"dev:jd": "npm run build:jd -- --watch",
"dev:jdrn": "node ./scripts/taro/generate-nutui-taro.js && taro build --type jdrn --watch --reset-cache",
"dev:jdhybrid": "npm run build:jdhybrid -- --watch",
"dev:quickapp": "npm run build:quickapp -- --watch",
"dev:weapp:jmapp": "VITE_APP_PROJECT_ID=jmapp npm run build:weapp -- --watch ",
"dev:swan:jmapp": "VITE_APP_PROJECT_ID=jmapp npm run build:swan -- --watch",
Expand All @@ -50,6 +53,9 @@
"@babel/runtime": "^7.23.9",
"@jdreact/jdreact-jsbundle-commonpack": "1.0.425",
"@jdtaro/plugin-platform-jdrn": "2.0.0-beta.0",
"@jdtaro/plugin-platform-jdhybrid": "0.2.1",
"@jdtaro/taro-platform-jdharmony": "2.0.70",
"@dongdesign/inject-jd-platform-styles": "^1.0.1",
"@nutui/touch-emulator": "^1.0.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
"@tarojs/components": "4.0.0-alpha.34",
Expand All @@ -70,16 +76,13 @@
"@tarojs/taro": "4.0.0-alpha.34",
"@tarojs/taro-h5": "4.0.0-alpha.34",
"babel-plugin-import": "^1.13.8",
"babel-plugin-module-resolver": "^5.0.2",
"babel-plugin-root-import": "^6.6.0",
"lodash.isequal": "^4.5.0",
"lodash.kebabcase": "^4.1.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.72.3",
"react-refresh": "^0.14.0",
"react-transition-group": "^4.4.5",
"webpack": "^5.91.0"
"react-transition-group": "^4.4.5"
},
"devDependencies": {
"@babel/core": "^7.23.9",
Expand Down
Loading