Skip to content

Commit

Permalink
Merge pull request #124 from j10ccc/chore/taro-migrate
Browse files Browse the repository at this point in the history
chore(taro): migrate configure to taro@4
  • Loading branch information
j10ccc authored Oct 24, 2024
2 parents fa72825 + fc03bc1 commit 089500f
Show file tree
Hide file tree
Showing 23 changed files with 2,427 additions and 4,921 deletions.
16 changes: 12 additions & 4 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# BaseUrl
HOST=https://sample.com
# 电费的模板id
ELECTRICITY_SUBSCRIBE_TEMPLID=
# 小程序运行时的变量,需要添加 VITE 前缀

# 服务端请求地址
VITE_HOST=
# 电费通知的模板 id
VITE_ELECTRICITY_SUBSCRIBE_TEMPLATE_ID=


# Taro 构建插件的变量,需要添加 TARO 前缀

# 小程序的 appid,会被自动填写到 dist/project.config.json
TARO_APP_ID=
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ node_modules/
.DS_Store
.idea
.swc

.env
.env.development
.env.production
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
{
framework: "vue3",
ts: true,
loose: false
compiler: "vite"
}
]
]
Expand Down
8 changes: 0 additions & 8 deletions config/dev.js

This file was deleted.

6 changes: 6 additions & 0 deletions config/dev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { UserConfigExport } from "@tarojs/cli";

export default {
mini: {},
h5: {}
} satisfies UserConfigExport<"vite">;
91 changes: 0 additions & 91 deletions config/index.js

This file was deleted.

54 changes: 54 additions & 0 deletions config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { UserConfigExport, defineConfig } from "@tarojs/cli";
import devConfig from "./dev";
import prodConfig from "./prod";
import path from "path";

export default defineConfig<"vite">(async (merge) => {
const baseConfig: UserConfigExport<"vite"> = {
projectName: "WeJh-Taro",
date: "2021-4-20",
designWidth: 750,
deviceRatio: {
640: 2.34 / 2,
750: 1,
375: 2,
828: 1.81 / 2
},
sourceRoot: "src",
outputRoot: "dist",
copy: {
patterns: [],
options: {}
},
plugins: [],
framework: "vue3",
compiler: "vite",
alias: {
"@": path.resolve(__dirname, "..", "src")
},
mini: {
postcss: {
htmltransform: {
enable: false
},
pxtransform: {
enable: true,
config: {}
},
cssModules: {
enable: true, // 默认为 false,如需使用 css modules 功能,则设为 true
config: {
namingPattern: "module", // 转换模式,取值为 global/module
generateScopedName: "[name]__[local]___[hash:base64:5]"
}
}
}
}
};

if (process.env.NODE_ENV === "development") {
return merge({}, baseConfig, devConfig);
}

return merge({}, baseConfig, prodConfig);
});
17 changes: 0 additions & 17 deletions config/prod.js

This file was deleted.

6 changes: 6 additions & 0 deletions config/prod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { UserConfigExport } from "@tarojs/cli";

export default {
mini: {},
h5: {}
} satisfies UserConfigExport<"vite">;
78 changes: 24 additions & 54 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,50 @@
"private": true,
"description": "",
"author": "ZJUTJH",
"templateInfo": {
"name": "default",
"typescript": true,
"css": "sass"
},
"scripts": {
"lint": "eslint",
"build:weapp": "taro build --type weapp",
"build:swan": "taro build --type swan",
"build:alipay": "taro build --type alipay",
"build:tt": "taro build --type tt",
"build:h5": "taro build --type h5",
"build:rn": "taro build --type rn",
"build:qq": "taro build --type qq",
"build:jd": "taro build --type jd",
"build:quickapp": "taro build --type quickapp",
"dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch",
"dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch",
"dev:qq": "npm run build:qq -- --watch",
"dev:jd": "npm run build:jd -- --watch",
"dev:quickapp": "npm run build:quickapp -- --watch"
"build:weapp": "taro build --type weapp"
},
"browserslist": [
"last 3 versions",
"Android >= 4.1",
"ios >= 8"
"defaults and fully supports es6-module",
"maintained node versions"
],
"dependencies": {
"@babel/runtime": "^7.7.7",
"@tarojs/components": "3.6.8",
"@tarojs/helper": "3.6.8",
"@tarojs/plugin-framework-vue3": "3.6.8",
"@tarojs/plugin-platform-alipay": "3.6.8",
"@tarojs/plugin-platform-h5": "3.6.8",
"@tarojs/plugin-platform-jd": "3.6.8",
"@tarojs/plugin-platform-qq": "3.6.8",
"@tarojs/plugin-platform-swan": "3.6.8",
"@tarojs/plugin-platform-tt": "3.6.8",
"@tarojs/plugin-platform-weapp": "3.6.8",
"@tarojs/runtime": "3.6.8",
"@tarojs/shared": "3.6.8",
"@tarojs/taro": "3.6.8",
"@babel/runtime": "^7.24.4",
"@tarojs/components": "4.0.6",
"@tarojs/helper": "4.0.6",
"@tarojs/plugin-platform-weapp": "4.0.6",
"@tarojs/runtime": "4.0.6",
"@tarojs/shared": "4.0.6",
"@tarojs/taro": "4.0.6",
"@tarojs/plugin-framework-vue3": "4.0.6",
"dayjs": "^1.11.4",
"lodash-es": "^4.17.21",
"vue": "^3.0.0",
"vuex": "^4.0.0",
"vuex-persistedstate": "^4.1.0"
},
"devDependencies": {
"@babel/core": "^7.8.0",
"@babel/core": "^7.24.4",
"@babel/plugin-proposal-class-properties": "7.14.5",
"@tarojs/cli": "4.0.6",
"@tarojs/vite-runner": "4.0.6",
"@stylistic/eslint-plugin": "^2.9.0",
"@tarojs/cli": "3.6.8",
"@tarojs/webpack5-runner": "3.6.8",
"@types/webpack-env": "^1.13.6",
"@vue/babel-plugin-jsx": "^1.0.6",
"@vue/compiler-sfc": "^3.0.0",
"@vue/eslint-config-typescript": "^14.0.0",
"babel-preset-taro": "3.6.8",
"css-loader": "3.4.2",
"dotenv": "^16.0.3",
"babel-preset-taro": "4.0.6",
"terser": "^5.30.4",
"vite": "^4.2.0",
"@vitejs/plugin-vue": "^5.0.4",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"eslint": "^9.12.0",
"stylelint": "^14.4.0",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-vue": "^9.28.0",
"globals": "^15.11.0",
"postcss": "^8.4.18",
"style-loader": "1.3.0",
"stylelint": "^14.4.0",
"typescript": "^4.1.0",
"vue-loader": "^17.0.0",
"webpack": "5.69.0"
"sass": "^1.75.0",
"typescript": "^5.4.5",
"postcss": "^8.4.38"
}
}
Loading

0 comments on commit 089500f

Please sign in to comment.