@ohos-ports/tarojs-cli 0.0.0-stage → 4.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +174 -0
- package/README.md +0 -3
- package/bin/taro +7 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +252 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/customCommand.d.ts +5 -0
- package/dist/commands/customCommand.js +23 -0
- package/dist/commands/customCommand.js.map +1 -0
- package/dist/config/index.d.ts +8 -0
- package/dist/config/index.js +10 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/packagesManagement.d.ts +19 -0
- package/dist/config/packagesManagement.js +22 -0
- package/dist/config/packagesManagement.js.map +1 -0
- package/dist/create/constants.d.ts +1 -0
- package/dist/create/constants.js +5 -0
- package/dist/create/constants.js.map +1 -0
- package/dist/create/creator.d.ts +9 -0
- package/dist/create/creator.js +31 -0
- package/dist/create/creator.js.map +1 -0
- package/dist/create/fetchTemplate.d.ts +8 -0
- package/dist/create/fetchTemplate.js +137 -0
- package/dist/create/fetchTemplate.js.map +1 -0
- package/dist/create/page.d.ts +65 -0
- package/dist/create/page.js +252 -0
- package/dist/create/page.js.map +1 -0
- package/dist/create/plugin.d.ts +16 -0
- package/dist/create/plugin.js +48 -0
- package/dist/create/plugin.js.map +1 -0
- package/dist/create/project.d.ts +80 -0
- package/dist/create/project.js +519 -0
- package/dist/create/project.js.map +1 -0
- package/dist/doctor/index.d.ts +4 -0
- package/dist/doctor/index.js +32 -0
- package/dist/doctor/index.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/presets/commands/build.d.ts +3 -0
- package/dist/presets/commands/build.js +239 -0
- package/dist/presets/commands/build.js.map +1 -0
- package/dist/presets/commands/config.d.ts +3 -0
- package/dist/presets/commands/config.js +88 -0
- package/dist/presets/commands/config.js.map +1 -0
- package/dist/presets/commands/create.d.ts +3 -0
- package/dist/presets/commands/create.js +91 -0
- package/dist/presets/commands/create.js.map +1 -0
- package/dist/presets/commands/global-config.d.ts +3 -0
- package/dist/presets/commands/global-config.js +139 -0
- package/dist/presets/commands/global-config.js.map +1 -0
- package/dist/presets/commands/help.d.ts +3 -0
- package/dist/presets/commands/help.js +29 -0
- package/dist/presets/commands/help.js.map +1 -0
- package/dist/presets/commands/info.d.ts +3 -0
- package/dist/presets/commands/info.js +79 -0
- package/dist/presets/commands/info.js.map +1 -0
- package/dist/presets/commands/init.d.ts +3 -0
- package/dist/presets/commands/init.js +59 -0
- package/dist/presets/commands/init.js.map +1 -0
- package/dist/presets/commands/inspect.d.ts +3 -0
- package/dist/presets/commands/inspect.js +118 -0
- package/dist/presets/commands/inspect.js.map +1 -0
- package/dist/presets/commands/update.d.ts +3 -0
- package/dist/presets/commands/update.js +171 -0
- package/dist/presets/commands/update.js.map +1 -0
- package/dist/presets/constant/hooks.d.ts +13 -0
- package/dist/presets/constant/hooks.js +17 -0
- package/dist/presets/constant/hooks.js.map +1 -0
- package/dist/presets/constant/index.d.ts +1 -0
- package/dist/presets/constant/index.js +18 -0
- package/dist/presets/constant/index.js.map +1 -0
- package/dist/presets/files/generateFrameworkInfo.d.ts +3 -0
- package/dist/presets/files/generateFrameworkInfo.js +30 -0
- package/dist/presets/files/generateFrameworkInfo.js.map +1 -0
- package/dist/presets/files/generateProjectConfig.d.ts +3 -0
- package/dist/presets/files/generateProjectConfig.js +40 -0
- package/dist/presets/files/generateProjectConfig.js.map +1 -0
- package/dist/presets/files/writeFileToDist.d.ts +3 -0
- package/dist/presets/files/writeFileToDist.js +17 -0
- package/dist/presets/files/writeFileToDist.js.map +1 -0
- package/dist/presets/hooks/build.d.ts +3 -0
- package/dist/presets/hooks/build.js +22 -0
- package/dist/presets/hooks/build.js.map +1 -0
- package/dist/presets/hooks/create.d.ts +3 -0
- package/dist/presets/hooks/create.js +11 -0
- package/dist/presets/hooks/create.js.map +1 -0
- package/dist/presets/index.d.ts +4 -0
- package/dist/presets/index.js +17 -0
- package/dist/presets/index.js.map +1 -0
- package/dist/presets/platforms/plugin.d.ts +3 -0
- package/dist/presets/platforms/plugin.js +76 -0
- package/dist/presets/platforms/plugin.js.map +1 -0
- package/dist/presets/platforms/rn.d.ts +3 -0
- package/dist/presets/platforms/rn.js +101 -0
- package/dist/presets/platforms/rn.js.map +1 -0
- package/dist/util/appConfig.d.ts +11 -0
- package/dist/util/appConfig.js +25 -0
- package/dist/util/appConfig.js.map +1 -0
- package/dist/util/createPage.d.ts +9 -0
- package/dist/util/createPage.js +117 -0
- package/dist/util/createPage.js.map +1 -0
- package/dist/util/defineConfig.d.ts +17 -0
- package/dist/util/defineConfig.js +12 -0
- package/dist/util/defineConfig.js.map +1 -0
- package/dist/util/index.d.ts +23 -0
- package/dist/util/index.js +125 -0
- package/dist/util/index.js.map +1 -0
- package/dist/util/types.d.ts +58 -0
- package/dist/util/types.js +3 -0
- package/dist/util/types.js.map +1 -0
- package/global.d.ts +4 -0
- package/index.js +3 -0
- package/package.json +76 -4
- package/postinstall.js +14 -0
- package/src/__tests__/__mocks__/presets.ts +15 -0
- package/src/__tests__/build-config.spec.ts +99 -0
- package/src/__tests__/cli.spec.ts +233 -0
- package/src/__tests__/config.spec.ts +232 -0
- package/src/__tests__/doctor-config.spec.ts +805 -0
- package/src/__tests__/doctor-eslint.spec.ts +31 -0
- package/src/__tests__/doctor-recommand.spec.ts +158 -0
- package/src/__tests__/doctor.spec.ts +77 -0
- package/src/__tests__/dotenv-parse.spec.ts +105 -0
- package/src/__tests__/env/.env +2 -0
- package/src/__tests__/fixtures/default/.env +3 -0
- package/src/__tests__/fixtures/default/.env.development +1 -0
- package/src/__tests__/fixtures/default/.env.local +1 -0
- package/src/__tests__/fixtures/default/.env.pre +3 -0
- package/src/__tests__/fixtures/default/.env.production +1 -0
- package/src/__tests__/fixtures/default/.env.uat +5 -0
- package/src/__tests__/fixtures/default/.env.uat.local +1 -0
- package/src/__tests__/fixtures/default/babel.config.js +10 -0
- package/src/__tests__/fixtures/default/config/dev.js +9 -0
- package/src/__tests__/fixtures/default/config/index.js +84 -0
- package/src/__tests__/fixtures/default/config/prod.js +18 -0
- package/src/__tests__/fixtures/default/package.json +38 -0
- package/src/__tests__/fixtures/default/src/app.config.js +11 -0
- package/src/__tests__/fixtures/default/src/app.js +16 -0
- package/src/__tests__/fixtures/default/src/app.scss +0 -0
- package/src/__tests__/fixtures/default/src/index.html +19 -0
- package/src/__tests__/fixtures/default/src/pages/index/index.config.js +3 -0
- package/src/__tests__/fixtures/default/src/pages/index/index.jsx +22 -0
- package/src/__tests__/fixtures/default/src/pages/index/index.scss +0 -0
- package/src/__tests__/info.spec.ts +74 -0
- package/src/__tests__/inspect.spec.ts +163 -0
- package/src/__tests__/project.spec.ts +304 -0
- package/src/__tests__/update.spec.ts +324 -0
- package/src/__tests__/utils/index.ts +54 -0
- package/src/cli.ts +250 -0
- package/src/commands/customCommand.ts +26 -0
- package/src/config/index.ts +7 -0
- package/src/config/manifest.default.json +35 -0
- package/src/config/packagesManagement.ts +20 -0
- package/src/config/rn-stylelint.json +5 -0
- package/src/config/tsconfig.json +24 -0
- package/src/create/constants.ts +1 -0
- package/src/create/creator.ts +37 -0
- package/src/create/fetchTemplate.ts +152 -0
- package/src/create/page.ts +299 -0
- package/src/create/plugin.ts +55 -0
- package/src/create/project.ts +591 -0
- package/src/doctor/index.ts +27 -0
- package/src/index.ts +24 -0
- package/src/presets/commands/build.ts +227 -0
- package/src/presets/commands/config.ts +86 -0
- package/src/presets/commands/create.ts +105 -0
- package/src/presets/commands/global-config.ts +140 -0
- package/src/presets/commands/help.ts +19 -0
- package/src/presets/commands/info.ts +77 -0
- package/src/presets/commands/init.ts +66 -0
- package/src/presets/commands/inspect.ts +138 -0
- package/src/presets/commands/update.ts +179 -0
- package/src/presets/constant/hooks.ts +14 -0
- package/src/presets/constant/index.ts +1 -0
- package/src/presets/files/generateFrameworkInfo.ts +30 -0
- package/src/presets/files/generateProjectConfig.ts +41 -0
- package/src/presets/files/writeFileToDist.ts +17 -0
- package/src/presets/hooks/build.ts +22 -0
- package/src/presets/hooks/create.ts +11 -0
- package/src/presets/index.ts +15 -0
- package/src/presets/platforms/plugin.ts +81 -0
- package/src/presets/platforms/rn.ts +113 -0
- package/src/util/appConfig.ts +29 -0
- package/src/util/createPage.ts +132 -0
- package/src/util/defineConfig.ts +22 -0
- package/src/util/index.ts +127 -0
- package/src/util/types.ts +81 -0
- package/templates/default/.husky/commit-msg +4 -0
- package/templates/default/_editorconfig +12 -0
- package/templates/default/_env.development +2 -0
- package/templates/default/_env.production +1 -0
- package/templates/default/_env.test +1 -0
- package/templates/default/_eslintrc +11 -0
- package/templates/default/_gitignore +8 -0
- package/templates/default/babel.config.js +14 -0
- package/templates/default/commitlint.config.mjs +1 -0
- package/templates/default/config/dev.js +10 -0
- package/templates/default/config/index.js +106 -0
- package/templates/default/config/prod.js +46 -0
- package/templates/default/package.json.tmpl +158 -0
- package/templates/default/project.config.json +15 -0
- package/templates/default/src/app.config.js +11 -0
- package/templates/default/src/app.css +0 -0
- package/templates/default/src/app.js +44 -0
- package/templates/default/src/index.html +17 -0
- package/templates/default/src/pages/index/index.config.js +3 -0
- package/templates/default/src/pages/index/index.css +0 -0
- package/templates/default/src/pages/index/index.jsx +15 -0
- package/templates/default/src/pages/index/index.vue +23 -0
- package/templates/default/stylelint.config.mjs +4 -0
- package/templates/default/template_creator.js +77 -0
- package/templates/default/tsconfig.json +32 -0
- package/templates/default/types/global.d.ts +35 -0
- package/templates/default/types/solid.d.ts +12 -0
- package/templates/default/types/vue.d.ts +10 -0
- package/templates/global-config/index.json +4 -0
- package/templates/global-config/package.json +5 -0
- package/templates/plugin-compile/README.md +32 -0
- package/templates/plugin-compile/index.js +3 -0
- package/templates/plugin-compile/package.json.tmpl +43 -0
- package/templates/plugin-compile/src/index.ts +153 -0
- package/templates/plugin-compile/tsconfig.json +29 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { defineConfig{{#if typescript }}, type UserConfigExport{{/if}} } from '@tarojs/cli'
|
|
2
|
+
{{#if typescript }}{{#unless (eq compiler "Vite")}}import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'{{/unless}}{{/if}}
|
|
3
|
+
import devConfig from './dev'
|
|
4
|
+
import prodConfig from './prod'
|
|
5
|
+
|
|
6
|
+
// https://taro-docs.jd.com/docs/next/config#defineconfig-辅助函数
|
|
7
|
+
export default defineConfig{{#if typescript }}<'{{ to_lower_case compiler }}'>{{/if}}(async (merge, { command, mode }) => {
|
|
8
|
+
const baseConfig{{#if typescript }}: UserConfigExport<'{{ to_lower_case compiler }}'>{{/if}} = {
|
|
9
|
+
projectName: '{{ projectName }}',
|
|
10
|
+
date: '{{ date }}',
|
|
11
|
+
designWidth: 750,
|
|
12
|
+
deviceRatio: {
|
|
13
|
+
640: 2.34 / 2,
|
|
14
|
+
750: 1,
|
|
15
|
+
375: 2,
|
|
16
|
+
828: 1.81 / 2
|
|
17
|
+
},
|
|
18
|
+
sourceRoot: 'src',
|
|
19
|
+
outputRoot: 'dist',
|
|
20
|
+
plugins: [
|
|
21
|
+
"@tarojs/plugin-generator"
|
|
22
|
+
],
|
|
23
|
+
defineConstants: {
|
|
24
|
+
},
|
|
25
|
+
copy: {
|
|
26
|
+
patterns: [
|
|
27
|
+
],
|
|
28
|
+
options: {
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
framework: '{{ to_lower_case framework }}',
|
|
32
|
+
compiler: '{{ to_lower_case compiler }}',{{#if (eq compiler "Webpack5") }}
|
|
33
|
+
cache: {
|
|
34
|
+
enable: false // Webpack 持久化缓存配置,建议开启。默认配置请参考:https://docs.taro.zone/docs/config-detail#cache
|
|
35
|
+
},{{/if}}{{#if (array_includes platforms "weapp" "alipay" "swan" "tt" "qq" "jd") }}
|
|
36
|
+
mini: {
|
|
37
|
+
postcss: {
|
|
38
|
+
pxtransform: {
|
|
39
|
+
enable: true,
|
|
40
|
+
config: {
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
cssModules: {
|
|
45
|
+
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
|
|
46
|
+
config: {
|
|
47
|
+
namingPattern: 'module', // 转换模式,取值为 global/module
|
|
48
|
+
generateScopedName: '[name]__[local]___[hash:base64:5]'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},{{#if typescript }}{{#unless (eq compiler "Vite")}}
|
|
52
|
+
webpackChain(chain) {
|
|
53
|
+
chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin)
|
|
54
|
+
}{{/unless}}{{/if}}
|
|
55
|
+
},{{/if}}{{#if (array_includes platforms "h5" "harmony-hybrid") }}
|
|
56
|
+
h5: {
|
|
57
|
+
publicPath: '/',
|
|
58
|
+
staticDirectory: 'static',
|
|
59
|
+
{{#unless (eq compiler "Vite")}}
|
|
60
|
+
output: {
|
|
61
|
+
filename: 'js/[name].[hash:8].js',
|
|
62
|
+
chunkFilename: 'js/[name].[chunkhash:8].js'
|
|
63
|
+
},{{/unless}}
|
|
64
|
+
miniCssExtractPluginOption: {
|
|
65
|
+
ignoreOrder: true,
|
|
66
|
+
filename: 'css/[name].[hash].css',
|
|
67
|
+
chunkFilename: 'css/[name].[chunkhash].css'
|
|
68
|
+
},
|
|
69
|
+
postcss: {
|
|
70
|
+
autoprefixer: {
|
|
71
|
+
enable: true,
|
|
72
|
+
config: {}
|
|
73
|
+
},
|
|
74
|
+
cssModules: {
|
|
75
|
+
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
|
|
76
|
+
config: {
|
|
77
|
+
namingPattern: 'module', // 转换模式,取值为 global/module
|
|
78
|
+
generateScopedName: '[name]__[local]___[hash:base64:5]'
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}{{#if typescript }},{{#unless (eq compiler "Vite")}}
|
|
82
|
+
webpackChain(chain) {
|
|
83
|
+
chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin)
|
|
84
|
+
}{{/unless}}{{/if}}
|
|
85
|
+
},{{/if}}{{#if (array_includes platforms "rn") }}
|
|
86
|
+
rn: {
|
|
87
|
+
appName: 'taroDemo',
|
|
88
|
+
postcss: {
|
|
89
|
+
cssModules: {
|
|
90
|
+
enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},{{/if}}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
{{#if buildEs5 }}
|
|
97
|
+
process.env.BROWSERSLIST_ENV = process.env.NODE_ENV
|
|
98
|
+
{{/if}}
|
|
99
|
+
|
|
100
|
+
if (process.env.NODE_ENV === 'development') {
|
|
101
|
+
// 本地开发构建配置(不混淆压缩)
|
|
102
|
+
return merge({}, baseConfig, devConfig)
|
|
103
|
+
}
|
|
104
|
+
// 生产构建配置(默认开启压缩混淆等)
|
|
105
|
+
return merge({}, baseConfig, prodConfig)
|
|
106
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{{#if typescript }}import type { UserConfigExport } from "@tarojs/cli"{{/if}}
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
mini: {},
|
|
5
|
+
h5: {
|
|
6
|
+
{{#if buildEs5 }}
|
|
7
|
+
{{#if (eq compiler 'Vite')}}
|
|
8
|
+
// 确保产物为 es5
|
|
9
|
+
legacy: true,
|
|
10
|
+
{{else if (eq compiler 'Webpack5')}}
|
|
11
|
+
compile: {
|
|
12
|
+
include: [
|
|
13
|
+
// 确保产物为 es5
|
|
14
|
+
filename => /node_modules\/(?!(@babel|core-js|style-loader|css-loader|react|react-dom))/.test(filename)
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{{/if}}
|
|
18
|
+
{{/if}}
|
|
19
|
+
/**
|
|
20
|
+
* WebpackChain 插件配置
|
|
21
|
+
* @docs https://github.com/neutrinojs/webpack-chain
|
|
22
|
+
*/
|
|
23
|
+
// webpackChain (chain) {
|
|
24
|
+
// /**
|
|
25
|
+
// * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。
|
|
26
|
+
// * @docs https://github.com/webpack-contrib/webpack-bundle-analyzer
|
|
27
|
+
// */
|
|
28
|
+
// chain.plugin('analyzer')
|
|
29
|
+
// .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
|
|
30
|
+
// /**
|
|
31
|
+
// * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。
|
|
32
|
+
// * @docs https://github.com/chrisvfritz/prerender-spa-plugin
|
|
33
|
+
// */
|
|
34
|
+
// const path = require('path')
|
|
35
|
+
// const Prerender = require('prerender-spa-plugin')
|
|
36
|
+
// const staticDir = path.join(__dirname, '..', 'dist')
|
|
37
|
+
// chain
|
|
38
|
+
// .plugin('prerender')
|
|
39
|
+
// .use(new Prerender({
|
|
40
|
+
// staticDir,
|
|
41
|
+
// routes: [ '/pages/index/index' ],
|
|
42
|
+
// postProcess: (context) => ({ ...context, outputPath: path.join(staticDir, 'index.html') })
|
|
43
|
+
// }))
|
|
44
|
+
// }
|
|
45
|
+
}
|
|
46
|
+
}{{#if typescript }} satisfies UserConfigExport<'{{ to_lower_case compiler }}'>{{/if}}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{ projectName }}",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "{{ description }}",
|
|
6
|
+
"templateInfo": {
|
|
7
|
+
"name": "{{ template }}",
|
|
8
|
+
"typescript": {{ typescript }},
|
|
9
|
+
"css": "{{ css }}",
|
|
10
|
+
"framework": "{{ framework }}"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"prepare": "husky",
|
|
14
|
+
"new": "taro new"{{#if (array_includes platforms "weapp")}},
|
|
15
|
+
"build:weapp": "taro build --type weapp",
|
|
16
|
+
"dev:weapp": "npm run build:weapp -- --watch"{{/if}}{{#if (array_includes platforms "swan")}},
|
|
17
|
+
"build:swan": "taro build --type swan",
|
|
18
|
+
"dev:swan": "npm run build:swan -- --watch"{{/if}}{{#if (array_includes platforms "alipay")}},
|
|
19
|
+
"build:alipay": "taro build --type alipay",
|
|
20
|
+
"dev:alipay": "npm run build:alipay -- --watch"{{/if}}{{#if (array_includes platforms "tt")}},
|
|
21
|
+
"build:tt": "taro build --type tt",
|
|
22
|
+
"dev:tt": "npm run build:tt -- --watch"{{/if}}{{#if (array_includes platforms "h5")}},
|
|
23
|
+
"build:h5": "taro build --type h5",
|
|
24
|
+
"dev:h5": "npm run build:h5 -- --watch"{{/if}}{{#if (array_includes platforms "rn")}},
|
|
25
|
+
"build:rn": "taro build --type rn",
|
|
26
|
+
"dev:rn": "npm run build:rn -- --watch"{{/if}}{{#if (array_includes platforms "qq")}},
|
|
27
|
+
"build:qq": "taro build --type qq",
|
|
28
|
+
"dev:qq": "npm run build:qq -- --watch"{{/if}}{{#if (array_includes platforms "jd")}},
|
|
29
|
+
"build:jd": "taro build --type jd",
|
|
30
|
+
"dev:jd": "npm run build:jd -- --watch"{{/if}}{{#if (array_includes platforms "harmony-hybrid")}},
|
|
31
|
+
"build:harmony-hybrid": "taro build --type harmony-hybrid",
|
|
32
|
+
"dev:harmony-hybrid": "npm run build:harmony-hybrid -- --watch"{{/if}}
|
|
33
|
+
},
|
|
34
|
+
{{#if buildEs5 }}
|
|
35
|
+
"browserslist": {
|
|
36
|
+
"development": [
|
|
37
|
+
"defaults and fully supports es6-module",
|
|
38
|
+
"maintained node versions"
|
|
39
|
+
],
|
|
40
|
+
"production": [
|
|
41
|
+
"last 3 versions",
|
|
42
|
+
"Android >= 4.1",
|
|
43
|
+
"ios >= 8"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{{else}}
|
|
47
|
+
"browserslist": [
|
|
48
|
+
"defaults and fully supports es6-module",
|
|
49
|
+
"maintained node versions"
|
|
50
|
+
],
|
|
51
|
+
{{/if}}
|
|
52
|
+
"author": "",
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@babel/runtime": "^7.24.4",
|
|
55
|
+
"@tarojs/components": "{{ version }}",
|
|
56
|
+
"@tarojs/helper": "{{ version }}",{{#if (array_includes platforms "weapp")}}
|
|
57
|
+
"@tarojs/plugin-platform-weapp": "{{ version }}",{{/if}}{{#if (array_includes platforms "alipay")}}
|
|
58
|
+
"@tarojs/plugin-platform-alipay": "{{ version }}",{{/if}}{{#if (array_includes platforms "tt")}}
|
|
59
|
+
"@tarojs/plugin-platform-tt": "{{ version }}",{{/if}}{{#if (array_includes platforms "swan")}}
|
|
60
|
+
"@tarojs/plugin-platform-swan": "{{ version }}",{{/if}}{{#if (array_includes platforms "jd")}}
|
|
61
|
+
"@tarojs/plugin-platform-jd": "{{ version }}",{{/if}}{{#if (array_includes platforms "qq")}}
|
|
62
|
+
"@tarojs/plugin-platform-qq": "{{ version }}",{{/if}}{{#if (array_includes platforms "h5")}}
|
|
63
|
+
"@tarojs/plugin-platform-h5": "{{ version }}",{{/if}}{{#if (array_includes platforms "harmony-hybrid")}}
|
|
64
|
+
"@tarojs/plugin-platform-harmony-hybrid": "{{ version }}",{{/if}}
|
|
65
|
+
"@tarojs/runtime": "{{ version }}",
|
|
66
|
+
"@tarojs/shared": "{{ version }}",
|
|
67
|
+
"@tarojs/taro": "{{ version }}",{{#if (includes "React" "Preact" s=framework)}}
|
|
68
|
+
"@tarojs/plugin-framework-react": "{{ version }}",{{/if}}{{#if (eq framework "React") }}
|
|
69
|
+
"@tarojs/react": "{{ version }}",
|
|
70
|
+
"react-dom": "^18.0.0",
|
|
71
|
+
"react": "^18.0.0"{{/if}}{{#if (eq framework "Preact") }}
|
|
72
|
+
"preact": "^10.5.15"{{/if}}{{#if (eq framework "Vue3") }}
|
|
73
|
+
"@tarojs/plugin-framework-vue3": "{{ version }}",
|
|
74
|
+
"vue": "^3.0.0"{{/if}}{{#if (eq framework "Solid") }}
|
|
75
|
+
"@tarojs/plugin-framework-solid": "{{ version }}",
|
|
76
|
+
"solid-js": "^1.8.16"{{/if}}
|
|
77
|
+
},{{#if (includes "Webpack5" s=compiler)}}
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@tarojs/plugin-generator": "{{ version }}",
|
|
80
|
+
"@commitlint/cli": "^19.8.1",
|
|
81
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
82
|
+
"lint-staged": "^16.1.2",
|
|
83
|
+
"husky": "^9.1.7",
|
|
84
|
+
"stylelint-config-standard": "^38.0.0",
|
|
85
|
+
"@babel/core": "^7.24.4",
|
|
86
|
+
"@tarojs/cli": "{{ version }}",
|
|
87
|
+
"@babel/plugin-transform-class-properties": "7.25.9",
|
|
88
|
+
"@types/webpack-env": "^1.13.6",{{#if (includes "React" "Preact" s=framework)}}
|
|
89
|
+
"@types/react": "^18.0.0",{{/if}}{{#if (eq compiler "Webpack5") }}
|
|
90
|
+
"webpack": "5.91.0",
|
|
91
|
+
"@tarojs/taro-loader": "{{ version }}",
|
|
92
|
+
"@tarojs/webpack5-runner": "{{ version }}",{{/if}}{{#if (eq css "Sass") }}
|
|
93
|
+
"sass": "^1.75.0",{{/if}}{{#if (eq css "Less") }}
|
|
94
|
+
"less": "^4.2.0",{{/if}}{{#if (eq css "Stylus") }}
|
|
95
|
+
"stylus": "^0.63.0",{{/if}}
|
|
96
|
+
"babel-preset-taro": "{{ version }}",{{#if (eq framework "Vue3") }}
|
|
97
|
+
"css-loader": "^7.1.1",
|
|
98
|
+
"style-loader": "^3.3.4",
|
|
99
|
+
"@tarojs/test-utils-vue3": "^0.1.1",
|
|
100
|
+
"@vue/babel-plugin-jsx": "^1.2.2",
|
|
101
|
+
"@vue/compiler-sfc": "^3.0.0",
|
|
102
|
+
"vue-loader": "^17.4.2",
|
|
103
|
+
"eslint-plugin-vue": "^9.17.0",{{/if}}
|
|
104
|
+
"eslint-config-taro": "{{ version }}",
|
|
105
|
+
"eslint": "^8.57.0",{{#if (eq framework "React") }}
|
|
106
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
|
|
107
|
+
"react-refresh": "^0.14.0",{{/if}}{{#if (eq framework "Preact") }}
|
|
108
|
+
"@prefresh/webpack": "^4",
|
|
109
|
+
"@prefresh/core": "^1.5.2",
|
|
110
|
+
"@prefresh/babel-plugin": "^0.5.1",{{/if}}{{#if (includes "React" "Preact" s=framework)}}
|
|
111
|
+
"@babel/preset-react": "^7.24.1",
|
|
112
|
+
"eslint-plugin-react": "^7.34.1",
|
|
113
|
+
"eslint-plugin-react-hooks": "^4.4.0",{{/if}}
|
|
114
|
+
"stylelint": "^16.4.0"{{#if typescript }},
|
|
115
|
+
"typescript": "^5.4.5",
|
|
116
|
+
"tsconfig-paths-webpack-plugin": "^4.1.0"{{/if}},
|
|
117
|
+
"postcss": "^8.5.6",
|
|
118
|
+
"@types/node": "^18",
|
|
119
|
+
"@types/minimatch": "^5"
|
|
120
|
+
}{{/if}}{{#if (eq compiler "Vite") }}
|
|
121
|
+
"devDependencies": {
|
|
122
|
+
"@tarojs/plugin-generator": "{{ version }}",
|
|
123
|
+
"@commitlint/cli": "^19.8.1",
|
|
124
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
125
|
+
"lint-staged": "^16.1.2",
|
|
126
|
+
"husky": "^9.1.7",
|
|
127
|
+
"stylelint-config-standard": "^38.0.0",
|
|
128
|
+
"@babel/core": "^7.24.4",
|
|
129
|
+
"@babel/plugin-transform-class-properties": "7.25.9",
|
|
130
|
+
"@tarojs/cli": "{{ version }}",
|
|
131
|
+
"@tarojs/vite-runner": "{{ version }}",
|
|
132
|
+
"babel-preset-taro": "{{ version }}",
|
|
133
|
+
"eslint-config-taro": "{{ version }}",
|
|
134
|
+
"eslint": "^8.57.0",
|
|
135
|
+
"stylelint": "^16.4.0",
|
|
136
|
+
"terser": "^5.30.4",
|
|
137
|
+
"vite": "^4.2.0",{{#if (includes "React" "Preact" s=framework)}}
|
|
138
|
+
"@babel/preset-react": "^7.24.1",
|
|
139
|
+
"@types/react": "^18.0.0",
|
|
140
|
+
"@vitejs/plugin-react": "^4.3.0",
|
|
141
|
+
"eslint-plugin-react": "^7.34.1",
|
|
142
|
+
"eslint-plugin-react-hooks": "^4.4.0",{{/if}}{{#if (eq framework "Preact") }}
|
|
143
|
+
"@preact/preset-vite": "^2.8.2",
|
|
144
|
+
"@prefresh/core": "^1.5.2",
|
|
145
|
+
"@prefresh/babel-plugin": "^0.5.1",{{/if}}{{#if (eq framework "React") }}
|
|
146
|
+
"react-refresh": "^0.14.0",{{/if}}{{#if (eq framework "Vue3") }}
|
|
147
|
+
"@vitejs/plugin-vue": "^5.0.4",
|
|
148
|
+
"@vitejs/plugin-vue-jsx": "^3.1.0",
|
|
149
|
+
"eslint-plugin-vue": "^9.17.0",{{/if}}{{#if (eq framework "Solid") }}
|
|
150
|
+
"vite-plugin-solid": "2.10.0",{{/if}}{{#if (eq css "Sass") }}
|
|
151
|
+
"sass": "^1.75.0",{{/if}}{{#if (eq css "Less") }}
|
|
152
|
+
"less": "^4.2.0",{{/if}}{{#if (eq css "Stylus") }}
|
|
153
|
+
"stylus": "^0.63.0",{{/if}}{{#if typescript }}
|
|
154
|
+
"typescript": "^5.4.5",{{/if}}
|
|
155
|
+
"postcss": "^8.5.6",
|
|
156
|
+
"@types/minimatch": "^5"
|
|
157
|
+
}{{/if}}
|
|
158
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"miniprogramRoot": "./dist",
|
|
3
|
+
"projectname": "{{ projectName }}",
|
|
4
|
+
"description": "{{ description }}",
|
|
5
|
+
"appid": "touristappid",
|
|
6
|
+
"setting": {
|
|
7
|
+
"urlCheck": true,
|
|
8
|
+
"es6": false,
|
|
9
|
+
"enhance": false,
|
|
10
|
+
"compileHotReLoad": false,
|
|
11
|
+
"postcss": false,
|
|
12
|
+
"minified": false
|
|
13
|
+
},
|
|
14
|
+
"compileType": "miniprogram"
|
|
15
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{{#if (includes "React" "Preact" s=framework)}}
|
|
2
|
+
{{#if typescript }}import { PropsWithChildren } from 'react'{{/if}}
|
|
3
|
+
import { useLaunch } from '@tarojs/taro'
|
|
4
|
+
{{/if}}{{#if (eq framework 'Vue3') }}
|
|
5
|
+
import { createApp } from 'vue'
|
|
6
|
+
{{/if}}{{#if (eq framework 'Solid') }}
|
|
7
|
+
{{#if typescript }}import { ParentProps } from 'solid-js'{{/if}}
|
|
8
|
+
import { useLaunch } from '@tarojs/taro'
|
|
9
|
+
{{/if}}
|
|
10
|
+
|
|
11
|
+
import './app.{{ cssExt }}'
|
|
12
|
+
|
|
13
|
+
{{#if (includes "React" "Preact" s=framework)}}
|
|
14
|
+
function App({ children }{{#if typescript }}: PropsWithChildren<any>{{/if}}) {
|
|
15
|
+
useLaunch(() => {
|
|
16
|
+
console.log('App launched.')
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
// children 是将要会渲染的页面
|
|
20
|
+
return children
|
|
21
|
+
}
|
|
22
|
+
{{/if}}
|
|
23
|
+
|
|
24
|
+
{{#if (eq framework 'Solid') }}
|
|
25
|
+
function App({ children }{{#if typescript }}: ParentProps{{/if}}) {
|
|
26
|
+
useLaunch(() => {
|
|
27
|
+
console.log('App launched.')
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
// children 是将要会渲染的页面
|
|
31
|
+
return children
|
|
32
|
+
}
|
|
33
|
+
{{/if}}
|
|
34
|
+
|
|
35
|
+
{{#if (eq framework 'Vue3') }}
|
|
36
|
+
const App = createApp({
|
|
37
|
+
onShow (options) {
|
|
38
|
+
console.log('App onShow.')
|
|
39
|
+
},
|
|
40
|
+
// 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖
|
|
41
|
+
})
|
|
42
|
+
{{/if}}
|
|
43
|
+
|
|
44
|
+
export default App
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
|
5
|
+
<meta content="width=device-width,initial-scale=1,user-scalable=no" name="viewport">
|
|
6
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
7
|
+
<meta name="apple-touch-fullscreen" content="yes">
|
|
8
|
+
<meta name="format-detection" content="telephone=no,address=no">
|
|
9
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="white">
|
|
10
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >
|
|
11
|
+
<title>{{ projectName }}</title>
|
|
12
|
+
<script><%= htmlWebpackPlugin.options.script %></script>
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<div id="app"></div>
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { View, Text } from '@tarojs/components'
|
|
2
|
+
import { useLoad } from '@tarojs/taro'
|
|
3
|
+
import './index.{{ cssExt }}'
|
|
4
|
+
|
|
5
|
+
export default function {{ to_pascal_case pageName }} () {
|
|
6
|
+
useLoad(() => {
|
|
7
|
+
console.log('Page loaded.')
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<View className='{{ pageName }}'>
|
|
12
|
+
<Text>Hello world!</Text>
|
|
13
|
+
</View>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="{{ pageName }}">
|
|
3
|
+
<text>\{{ msg }}</text>
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
{{#if (eq framework 'Vue3') }}
|
|
9
|
+
import { ref } from 'vue'
|
|
10
|
+
{{/if}}
|
|
11
|
+
import './index.{{ cssExt }}'
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
{{#if (eq framework 'Vue3') }}
|
|
15
|
+
setup () {
|
|
16
|
+
const msg = ref('Hello world')
|
|
17
|
+
return {
|
|
18
|
+
msg
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
{{/if}}
|
|
22
|
+
}
|
|
23
|
+
</script>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
|
|
3
|
+
function createWhenTs (err, params) {
|
|
4
|
+
return !!params.typescript
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function normalizePath (path) {
|
|
8
|
+
return path.replace(/\\/g, '/').replace(/\/{2,}/g, '/')
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const SOURCE_ENTRY = '/src'
|
|
12
|
+
const PAGES_ENTRY = '/src/pages'
|
|
13
|
+
|
|
14
|
+
const handler = {
|
|
15
|
+
'/tsconfig.json': createWhenTs,
|
|
16
|
+
'/types/global.d.ts': createWhenTs,
|
|
17
|
+
'/types/vue.d.ts' (err, { framework, typescript }) {
|
|
18
|
+
return ['Vue3'].includes(framework) && !!typescript
|
|
19
|
+
},
|
|
20
|
+
'/types/solid.d.ts' (err, { framework, typescript }) {
|
|
21
|
+
return ['Solid'].includes(framework) && !!typescript
|
|
22
|
+
},
|
|
23
|
+
'/src/pages/index/index.jsx' (err, { pageDir = '', pageName = '', subPkg = '' }) {
|
|
24
|
+
return {
|
|
25
|
+
setPageName: normalizePath(path.join(PAGES_ENTRY, pageDir, pageName, 'index.jsx')),
|
|
26
|
+
setSubPkgName: normalizePath(path.join(SOURCE_ENTRY, subPkg, pageDir, pageName, 'index.jsx'))
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
'/src/pages/index/index.css' (err, { pageDir = '', pageName = '', subPkg = '' }) {
|
|
30
|
+
return {
|
|
31
|
+
setPageName: normalizePath(path.join(PAGES_ENTRY, pageDir, pageName, 'index.css')),
|
|
32
|
+
setSubPkgName: normalizePath(path.join(SOURCE_ENTRY, subPkg, pageDir, pageName, 'index.css'))
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
'/src/pages/index/index.vue' (err, { pageDir = '', pageName = '', subPkg = '' }) {
|
|
36
|
+
return {
|
|
37
|
+
setPageName: normalizePath(path.join(PAGES_ENTRY, pageDir, pageName, 'index.vue')),
|
|
38
|
+
setSubPkgName: normalizePath(path.join(SOURCE_ENTRY, subPkg, pageDir, pageName, 'index.vue'))
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
'/src/pages/index/index.config.js' (err, { pageDir = '', pageName = '', subPkg = '' }) {
|
|
42
|
+
return {
|
|
43
|
+
setPageName: normalizePath(path.join(PAGES_ENTRY, pageDir, pageName, 'index.config.js')),
|
|
44
|
+
setSubPkgName: normalizePath(path.join(SOURCE_ENTRY, subPkg, pageDir, pageName, 'index.config.js'))
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
'/_editorconfig' () {
|
|
48
|
+
return { setPageName: `/.editorconfig` }
|
|
49
|
+
},
|
|
50
|
+
'/_env.development' () {
|
|
51
|
+
return { setPageName: `/.env.development` }
|
|
52
|
+
},
|
|
53
|
+
'/_env.production' () {
|
|
54
|
+
return { setPageName: `/.env.production` }
|
|
55
|
+
},
|
|
56
|
+
'/_env.test' () {
|
|
57
|
+
return { setPageName: `/.env.test` }
|
|
58
|
+
},
|
|
59
|
+
'/_eslintrc' () {
|
|
60
|
+
return { setPageName: `/.eslintrc` }
|
|
61
|
+
},
|
|
62
|
+
'/_gitignore' () {
|
|
63
|
+
return { setPageName: `/.gitignore` }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const basePageFiles = [
|
|
68
|
+
'/src/pages/index/index.jsx',
|
|
69
|
+
'/src/pages/index/index.vue',
|
|
70
|
+
'/src/pages/index/index.css',
|
|
71
|
+
'/src/pages/index/index.config.js'
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
module.exports = {
|
|
75
|
+
handler,
|
|
76
|
+
basePageFiles
|
|
77
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2017",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"removeComments": false,
|
|
6
|
+
"preserveConstEnums": true,
|
|
7
|
+
"moduleResolution": "node",
|
|
8
|
+
"experimentalDecorators": true,
|
|
9
|
+
"noImplicitAny": false,
|
|
10
|
+
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"outDir": "lib",
|
|
12
|
+
"noUnusedLocals": true,
|
|
13
|
+
"noUnusedParameters": true,
|
|
14
|
+
"strictNullChecks": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"rootDir": ".",
|
|
17
|
+
"jsx": "{{#if (includes "Vue3" s=framework)}}preserve{{else if (eq framework 'Solid')}}preserve{{else}}react-jsx{{/if}}",{{#if (eq framework "Preact") }}
|
|
18
|
+
"skipLibCheck": true,{{/if}}
|
|
19
|
+
"allowJs": true,{{#if (eq framework "Solid")}}
|
|
20
|
+
"jsxImportSource": "solid-js",{{/if}}
|
|
21
|
+
"resolveJsonModule": true,
|
|
22
|
+
"typeRoots": [
|
|
23
|
+
"node_modules/@types"
|
|
24
|
+
],
|
|
25
|
+
"paths": {
|
|
26
|
+
// TS5090 leading './'
|
|
27
|
+
"@/*": ["./src/*"]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"include": ["./src", "./types", "./config"],
|
|
31
|
+
"compileOnSave": false
|
|
32
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="@tarojs/taro" />
|
|
2
|
+
|
|
3
|
+
declare module '*.png';
|
|
4
|
+
declare module '*.gif';
|
|
5
|
+
declare module '*.jpg';
|
|
6
|
+
declare module '*.jpeg';
|
|
7
|
+
declare module '*.svg';
|
|
8
|
+
declare module '*.css';
|
|
9
|
+
declare module '*.less';
|
|
10
|
+
declare module '*.scss';
|
|
11
|
+
declare module '*.sass';
|
|
12
|
+
declare module '*.styl';
|
|
13
|
+
|
|
14
|
+
declare namespace NodeJS {
|
|
15
|
+
interface ProcessEnv {
|
|
16
|
+
/** NODE 内置环境变量, 会影响到最终构建生成产物 */
|
|
17
|
+
NODE_ENV: 'development' | 'production',
|
|
18
|
+
/** 当前构建的平台 */
|
|
19
|
+
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'qq' | 'jd' | 'harmony' | 'jdrn'
|
|
20
|
+
/**
|
|
21
|
+
* 当前构建的小程序 appid
|
|
22
|
+
* @description 若不同环境有不同的小程序,可通过在 env 文件中配置环境变量`TARO_APP_ID`来方便快速切换 appid, 而不必手动去修改 dist/project.config.json 文件
|
|
23
|
+
* @see https://taro-docs.jd.com/docs/next/env-mode-config#特殊环境变量-taro_app_id
|
|
24
|
+
*/
|
|
25
|
+
TARO_APP_ID: string
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
{{#if (includes "Vue3" s=framework)}}
|
|
30
|
+
declare module '@tarojs/components' {
|
|
31
|
+
export * from '@tarojs/components/types/index.vue3'
|
|
32
|
+
}{{else if (includes "Solid" s=framework)}}
|
|
33
|
+
declare module '@tarojs/components' {
|
|
34
|
+
export * from '@tarojs/components/types/index.solid'
|
|
35
|
+
}{{/if}}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export {}
|
|
2
|
+
|
|
3
|
+
declare module 'vue' {
|
|
4
|
+
export interface GlobalComponents extends JSX.IntrinsicElements {
|
|
5
|
+
/** Note: Vue 在 runtime 中将 JSX.IntrinsicElements 通过 index signature 重复声明标签
|
|
6
|
+
* 这会导致插件无法正常跳转类型,可以手动覆盖声明标签活得更好的体验,参考如下:
|
|
7
|
+
* 'scroll-view': JSX.IntrinsicElements['scroll-view']
|
|
8
|
+
*/
|
|
9
|
+
}
|
|
10
|
+
}
|