A wechat miniprogram template project the best practice with TypeScript and VSCode
[Best practice for mini program templates (TypeScript+VSCode), built using the miniprogram-build tool]
npm
>= 6.0 (or yarn
) Node
>= 10服务端口
) Click Use this template to use this template with one click, or use the command line:
# 不指定`[本地目录]`则在当前目录创建,`-n`表示使用最新模板
npm create miniprogram NewFuture/miniprogram-template -n [本地目录]
# 或者
# yarn create miniprogram NewFuture/miniprogram-template -n [本地目录]
# cd [本地目录名]
npm start
# 或者
# yarn start
After normal startup, the debugging tool will automatically open the dist
preview.
npm
can be replaced byyarn
npm start
: Recompile the project and update it in real time [alias npm run start
]npm run start:test
: Use the test environment configuration file for developmentnpm run start:prod
: Use the build environment configuration file for developmentnpm run upload
: Package and upload the project to the mini program background (development environment configuration)npm run upload:test
: Use the test environment configuration to package and upload the project to the mini program backgroundnpm run upload:prod
: Use the build environment configuration to package and upload the project to the mini program backgroundnpm run build
: Repackage and compile (development environment configuration)npm run build:test
: Repackage and compilenpm run build:prod
: repackage and compilenpm test
: test [alias npm run test
]npm run check
: Code style and format checking (supports separate lint
checks in different languages)npm run fix
: Automatically fix fixable lint and code style issuesnpm run help
: View detailed usage of the compilation tool mpAll shortcut commands package.json
Each environment can be configured differently (environment configuration can be increased or reduced as needed)
.mpconfig.jsonc
development integrated environmentenv/test.jsonc
test environment configurationenv/prod.jsonc
online production environment configurationIf there is only one environment, you can delete the
env
directory and configure it directly using.mpconfig.jsonc
.ts
(TypeScript) or .js
(JavaScript) ( ts
recommended )/
absolute path form import .wxml
or .html
.scss
, .sass
or .css
( scss
recommended)scss
can directly @import
the contents of the assets directory .jsonc
, .json
or .json5
annotations supported.wxts
(TypeScript), .wxs
(JavaScript) ( wxts
recommended)miniprogram-wxs
performs type checking and qualificationUse
VSCode
and automatically install recommended plug-ins
Page
, Component
, wxs
will automatically generate template files (the template can be modified) Auzre Pipelines, Travis CI and Github Actions have been configured by default and can be opened and modified as needed.