Skip to content

Commit

Permalink
feat: big change
Browse files Browse the repository at this point in the history
  • Loading branch information
icai committed Apr 9, 2024
1 parent 9d69e33 commit 7aa8ad4
Show file tree
Hide file tree
Showing 105 changed files with 17,440 additions and 3,093 deletions.
23 changes: 20 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,24 @@
"extends": ["taro"],
"rules": {
"no-unused-vars": ["error", { "varsIgnorePattern": "Taro" }],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".tsx"] }]
},
"parser": "babel-eslint"
"react/jsx-filename-extension": [
1,
{ "extensions": [".js", ".jsx", ".tsx"] }
],
"react/require-default-props": 0,
"import/order": [
1,
{
"groups": [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index"
],
"newlines-between": "never"
}
]
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
dist/
deploy_versions/
.temp/
.rn_temp/
node_modules/
.DS_Store
.swc
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"path-intellisense.mappings": {
"/": "${workspaceRoot}/src/"
},
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.fixAll.tslint": "explicit",
"source.fixAll.stylelint": "explicit"
}
}
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@

git clone --depth 50 -b master --single-branch https://github.com/icai/taro-cnode.git && cd taro-cnode

npm install -g @tarojs/cli
pnpm install -g @tarojs/cli

npm install
pnpm install

pnpm run dev:wepp

npm run dev:h5

```

Expand All @@ -44,28 +45,23 @@ http://taro.w3cub.com/

- 小程序地址

还在调试中,待定



taro 完整程序可以参考:

taro-ui 参考:

https://github.com/cpitax/taro-tax



## 声明

本程序一开始存在一个错误的兼容方向。按照Taro的设计原理,应该先兼容小程序再兼容其他端。
本工程本来基于 https://github.com/shinygang/Vue-cnodejs 开发而来,所以一开始是兼容H5为主,
但是到了后续Taro的升级,存在各种Taro API向小程序靠拢的迹象, 很多ES6,React的屏蔽。
所以假如要用Taro开发,建议先以**小程序**为主端,向多端扩散。


基于 https://github.com/shinygang/Vue-cnodejs 和 taro-cli 实现



## LICENSE

Copyright (c) 2018 Terry Cai. Licensed under the MIT license.
Copyright (c) 2018 - 2024 Terry Cai. Licensed under the MIT license.
22 changes: 22 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// babel-preset-taro 更多选项和默认值:
// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
module.exports = {
presets: [
['taro', {
framework: 'react',
ts: true
}]
],
plugins: [
[
"import",
{
"libraryName": "@nutui/nutui-react-taro",
"libraryDirectory": "dist/esm",
"style": 'css',
"camel2DashComponentName": false
},
'nutui-react-taro'
]
]
}
2 changes: 1 addition & 1 deletion config/dev.js → config/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module.exports = {
},
defineConstants: {
},
weapp: {},
mini: {},
h5: {}
}
72 changes: 0 additions & 72 deletions config/index.js

This file was deleted.

105 changes: 105 additions & 0 deletions config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
const config = {
projectName: 'trao-cnode3',
date: '2024-4-6',
designWidth: 750,
deviceRatio: {
640: 2.34 / 2,
750: 1,
828: 1.81 / 2,
375: 2 / 1
},
sourceRoot: 'src',
outputRoot: 'dist',
plugins: ['@tarojs/plugin-html'],
defineConstants: {
},
copy: {
patterns: [
],
options: {
}
},
framework: 'react',
compiler: {
type: 'webpack5',
prebundle: { enable: false }
},
alias: {
'@': require('path').resolve(__dirname, '..', 'src')
},

// resolve.fallback: { "util": false },
resolve: {
fallback: {
"util": require.resolve("util/"),
}
},
sass: {
resource: require('path').resolve(__dirname, '..', 'src/assets/scss/_variable.scss'),
},
mini: {
miniCssExtractPluginOption: {
ignoreOrder: true,
},
postcss: {
pxtransform: {
enable: true,
config: {
selectorBlackList: ['nut-']
}
},
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',
esnextModules: ['nutui-react'],
// module: {
// postcss: {
// autoprefixer: {
// enable: true
// }
// }
// },
postcss: {
pxtransform: {
enable: true,
config: {
selectorBlackList: ['nut-']
}
},
autoprefixer: {
enable: true,
config: {
}
},
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'))
}
9 changes: 0 additions & 9 deletions config/prod.js

This file was deleted.

37 changes: 37 additions & 0 deletions config/prod.ts
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') })
// }))
// }
}
}
11 changes: 11 additions & 0 deletions mini.project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"format": 2,
"compileOptions": {
"transpile": {
"script": {
"ignore": ["node_modules/**"]
}
},
"component2": true
}
}
Loading

0 comments on commit 7aa8ad4

Please sign in to comment.