WeChat/Alipay mini program project scaffolding developed using webpack
, babel
, scss
node_modules
modulesalias
to avoid module references such as ../../../
ES6
compatibility through babel
, including async/await
promise
and lodash
( lodash
introduces corresponding modules on demand, not all)scss
to write .wxss
files, with some useful mixins
and extends
built-in__DEV__
and process.env.NODE_ENV
global constants to assist development__WECHAT__
and __ALIPAY__
global constants to determine whether it is a WeChat applet or Alipay appletproduction
environment Make sure you have Node.js (>= v4.2
) and yarn or npm installed
git clone
this projectcd
to this directory and execute yarn
to install dependent modules.yarn start
to start developmentdist/wechat
directory to the project yarn start
starts webpack
to develop WeChat applet projects, which can monitor file changes and automatically recompileyarn start:alipay
starts webpack
to develop Alipay applet project, which can monitor file changes and automatically recompileyarn build
compiles and generates the code for production
environment to dist/wechat
and dist/alipay
yarn lint:build
executes the yarn build
command and uses eslint and stylelint to verify code specificationsyarn prettier
executes prettier
to format the code in the src directoryyarn create-page
quickly creates a WeChat applet page (for more usage of create-page
, please see create-wxapp-page) Developers can choose a set of source codes to develop WeChat and Alipay applets. This scaffolding supports automatic compilation wxml
to axml
, conversion of wx:attr
to a:attr
, conversion of API wx
to my
, and vice versa. However, individual interfaces are slightly different on the platform, and developers can dynamically handle them through __WECHAT__
or __ALIPAY__
.
If wxml
or axml
has dynamically imported files (such as src="{{'images/' + type + '.png'}}"
), webpack will not be able to dynamically import them, so there may be missing files after packaging.
If you encounter this situation, you can solve it through copy-webpack-plugin and copy the entire images
directory to dist
.
This plugin already has this plug-in built into this scaffolding. For ease of use, you can also add a copyWebpack
string array to package.json
to automatically copy directories or files. For example:
package.json
{
// ...
"copyWebpack" : [ "images" , "icons" ]
}
By executing yarn start
or yarn build
, the src/images
and src/icons
directories will be automatically copied to dist/wechat/images
and dist/wechat/icons
directories (the same applies to the Alipay applet).
Changelog
MIT