forked from NervJS/taro
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(h5): 完善原生组件编译功能和 demo (NervJS#15188)
* feat: 完善原生组件编译功能和 demo * test: 更新 example 依赖 * chore(release): publish 3.6.24-nightly.0 --tag=nightly * feat: 组件编译模式下默认禁用代码分割,并完善组件编译模式下的代码示例 * chore(release): publish 3.6.23 * feat: 更新 blended demo --------- Co-authored-by: xuanzebin <xuanzebin3@jd.com>
- Loading branch information
Showing
58 changed files
with
31,788 additions
and
6,441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ miniapp/taro | |
taro-project/dist | ||
**/node_modules | ||
.DS_Store | ||
h5/src/taro | ||
h5-html/src/taro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
<link rel="stylesheet" href="./src/taro/css/components/picker/index.css"> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script src="https://cdn.bootcdn.net/ajax/libs/vue/3.3.4/vue.global.js"></script> | ||
<script src="./src/taro/components/picker/index.js"></script> | ||
<script> | ||
// 定义应用程序的根组件 | ||
const App = { | ||
components: { | ||
MyPicker: window.NativeComponent.default | ||
}, | ||
template: ` | ||
<view> | ||
<view>Detail: </view> | ||
<button @click="goto">Go To Detail</button> | ||
<view>Picker: </view> | ||
<my-picker title="test" :list="list" @button-click="onButtonClick"></my-picker> | ||
</view> | ||
`, | ||
data() { | ||
return { | ||
list: ['Item 1', 'Item 2', 'Item 3'] // 示例数据 | ||
}; | ||
}, | ||
methods: { | ||
goto() { | ||
console.log('Going to detail...'); | ||
// 实现跳转逻辑 | ||
}, | ||
onButtonClick(data) { | ||
console.log('Button clicked with:', data); | ||
// 实现按钮点击逻辑 | ||
} | ||
} | ||
}; | ||
// 创建并挂载至 #app | ||
Vue.createApp(App).mount('#root'); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// ESLint 检查 .vue 文件需要单独配置编辑器: | ||
// https://eslint.vuejs.org/user-guide/#editor-integrations | ||
{ | ||
"extends": ["taro/vue3"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dist/ | ||
deploy_versions/ | ||
.temp/ | ||
.rn_temp/ | ||
node_modules/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// babel-preset-taro 更多选项和默认值: | ||
// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md | ||
module.exports = { | ||
presets: [ | ||
['taro', { | ||
framework: 'vue3', | ||
ts: true | ||
}] | ||
], | ||
plugins: [ | ||
[ | ||
"import", | ||
{ | ||
"libraryName": "@nutui/nutui-taro", | ||
"libraryDirectory": "dist/packages/_es", | ||
// customName自定义兼容国际化使用 | ||
"customName": (name, file) => { | ||
if (name == 'Locale') { | ||
return '@nutui/nutui-taro/dist/packages/locale/lang'; | ||
} else { | ||
return `@nutui/nutui-taro/dist/packages/_es/${name}`; | ||
} | ||
}, | ||
"style": (name, file) => name.toLowerCase().replace('_es/', '') + '/index.scss', | ||
"camel2DashComponentName": false | ||
}, | ||
'nutui3-taro' | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
env: { | ||
NODE_ENV: '"development"' | ||
}, | ||
defineConstants: { | ||
}, | ||
mini: {}, | ||
h5: {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
const path = require('path') | ||
|
||
const config = { | ||
projectName: 'blended-taro-component-vue3', | ||
date: '2022-9-2', | ||
designWidth: 375, | ||
deviceRatio: { | ||
640: 2.34 / 2, | ||
750: 1, | ||
828: 1.81 / 2, | ||
375: 2 / 1 | ||
}, | ||
sourceRoot: 'src', | ||
outputRoot: 'dist', | ||
plugins: [ | ||
'@tarojs/plugin-html' | ||
], | ||
sass: { | ||
data: `@import "@nutui/nutui-taro/dist/styles/variables.scss";`, | ||
}, | ||
defineConstants: { | ||
}, | ||
copy: { | ||
patterns: [ | ||
], | ||
options: { | ||
} | ||
}, | ||
framework: 'vue3', | ||
compiler: { | ||
type: 'webpack5', | ||
prebundle: { | ||
enable: false | ||
} | ||
}, | ||
mini: { | ||
postcss: { | ||
pxtransform: { | ||
enable: true, | ||
config: { | ||
|
||
} | ||
}, | ||
url: { | ||
enable: true, | ||
config: { | ||
limit: 1024 // 设定转换尺寸上限 | ||
} | ||
}, | ||
cssModules: { | ||
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true | ||
config: { | ||
namingPattern: 'module', // 转换模式,取值为 global/module | ||
generateScopedName: '[name]__[local]___[hash:base64:5]' | ||
} | ||
} | ||
} | ||
}, | ||
h5: { | ||
publicPath: '/', | ||
staticDirectory: 'static', | ||
postcss: { | ||
autoprefixer: { | ||
enable: true, | ||
config: { | ||
} | ||
}, | ||
cssModules: { | ||
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true | ||
config: { | ||
namingPattern: 'module', // 转换模式,取值为 global/module | ||
generateScopedName: '[name]__[local]___[hash:base64:5]' | ||
} | ||
} | ||
} | ||
}, | ||
rn: { | ||
appName: 'taroDemo', | ||
postcss: { | ||
cssModules: { | ||
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true | ||
} | ||
} | ||
} | ||
} | ||
|
||
module.exports = function (merge) { | ||
if (process.env.NODE_ENV === 'development') { | ||
return merge({}, config, require('./dev')) | ||
} | ||
return merge({}, config, require('./prod')) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module.exports = { | ||
env: { | ||
NODE_ENV: '"production"' | ||
}, | ||
defineConstants: { | ||
}, | ||
mini: {}, | ||
h5: { | ||
/** | ||
* WebpackChain 插件配置 | ||
* @docs https://github.com/neutrinojs/webpack-chain | ||
*/ | ||
// webpackChain (chain) { | ||
// /** | ||
// * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。 | ||
// * @docs https://github.com/webpack-contrib/webpack-bundle-analyzer | ||
// */ | ||
// chain.plugin('analyzer') | ||
// .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, []) | ||
|
||
// /** | ||
// * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。 | ||
// * @docs https://github.com/chrisvfritz/prerender-spa-plugin | ||
// */ | ||
// const path = require('path') | ||
// const Prerender = require('prerender-spa-plugin') | ||
// const staticDir = path.join(__dirname, '..', 'dist') | ||
// chain | ||
// .plugin('prerender') | ||
// .use(new Prerender({ | ||
// staticDir, | ||
// routes: [ '/pages/index/index' ], | ||
// postProcess: (context) => ({ ...context, outputPath: path.join(staticDir, 'index.html') }) | ||
// })) | ||
// } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"name": "blended-taro-component-vue3", | ||
"version": "1.0.0", | ||
"private": true, | ||
"description": "", | ||
"templateInfo": { | ||
"name": "default", | ||
"typescript": true, | ||
"css": "sass" | ||
}, | ||
"scripts": { | ||
"build": "taro build native-components --type weapp", | ||
"dev": "taro build --type weapp --watch", | ||
"build:h5": "taro build native-components --type h5", | ||
"dev:h5": "taro build --type h5 --watch" | ||
}, | ||
"browserslist": [ | ||
"last 3 versions", | ||
"Android >= 4.1", | ||
"ios >= 8" | ||
], | ||
"author": "", | ||
"dependencies": { | ||
"@babel/runtime": "^7.7.7", | ||
"@nutui/nutui-taro": "^3.2.1", | ||
"@tarojs/components": "3.6.24", | ||
"@tarojs/helper": "3.6.24", | ||
"@tarojs/plugin-framework-vue3": "3.6.24", | ||
"@tarojs/plugin-platform-alipay": "3.6.24", | ||
"@tarojs/plugin-platform-jd": "3.6.24", | ||
"@tarojs/plugin-platform-qq": "3.6.24", | ||
"@tarojs/plugin-platform-swan": "3.6.24", | ||
"@tarojs/plugin-platform-tt": "3.6.24", | ||
"@tarojs/plugin-platform-h5": "3.6.24", | ||
"@tarojs/plugin-platform-weapp": "3.6.24", | ||
"@tarojs/router": "3.6.24", | ||
"@tarojs/runtime": "3.6.24", | ||
"@tarojs/shared": "3.6.24", | ||
"@tarojs/taro": "3.6.24", | ||
"@tarojs/taro-h5": "3.6.24", | ||
"vue": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.8.0", | ||
"@tarojs/cli": "3.6.24", | ||
"@tarojs/mini-runner": "3.6.24", | ||
"@tarojs/plugin-html": "^3.6.24", | ||
"@tarojs/webpack5-runner": "^3.6.24", | ||
"@types/webpack-env": "^1.13.6", | ||
"@typescript-eslint/eslint-plugin": "^5.20.0", | ||
"@typescript-eslint/parser": "^5.20.0", | ||
"@vue/babel-plugin-jsx": "^1.0.6", | ||
"@vue/compiler-sfc": "^3.0.0", | ||
"babel-plugin-import": "^1.13.5", | ||
"babel-preset-taro": "3.6.24", | ||
"css-loader": "3.4.2", | ||
"eslint": "^8.12.0", | ||
"eslint-config-taro": "3.6.24", | ||
"eslint-plugin-vue": "^8.0.0", | ||
"style-loader": "1.3.0", | ||
"stylelint": "^14.4.0", | ||
"typescript": "^4.1.0", | ||
"vue-loader": "^17.0.0", | ||
"webpack": "5.78.0" | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
examples/blended-taro-component-vue3/h5/project.config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"miniprogramRoot": "./dist", | ||
"projectname": "blended-taro-component-vue3", | ||
"description": "", | ||
"appid": "touristappid", | ||
"setting": { | ||
"urlCheck": true, | ||
"es6": false, | ||
"enhance": false, | ||
"compileHotReLoad": false, | ||
"postcss": false, | ||
"minified": false | ||
}, | ||
"compileType": "miniprogram" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"miniprogramRoot": "./", | ||
"projectname": "blended-taro-component-vue3", | ||
"appid": "testAppId", | ||
"setting": { | ||
"es6": false, | ||
"minified": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default defineAppConfig({ | ||
pages: [ | ||
'pages/index/index' | ||
], | ||
window: { | ||
backgroundTextStyle: 'light', | ||
navigationBarBackgroundColor: '#fff', | ||
navigationBarTitleText: 'WeChat', | ||
navigationBarTextStyle: 'black' | ||
} | ||
}) |
Empty file.
Oops, something went wrong.