{"id":21588931,"url":"https://github.com/cantonjs/wxapp-boilerplate","last_synced_at":"2025-04-06T04:12:14.399Z","repository":{"id":19736042,"uuid":"87760975","full_name":"cantonjs/wxapp-boilerplate","owner":"cantonjs","description":"使用 webpack, babel, scss 开发的微信/支付宝小程序项目脚手架","archived":false,"fork":false,"pushed_at":"2022-12-06T19:47:40.000Z","size":2159,"stargazers_count":378,"open_issues_count":37,"forks_count":60,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-08-27T12:28:16.308Z","etag":null,"topics":["alipay","alipay-mini-program","babel","boilerplate","lib-boilerplate","mini-program","scss","weapp","webpack","wechat","wechat-mini-program","wxapp","wxapp-boilerplate"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cantonjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-10T03:07:53.000Z","updated_at":"2024-05-17T01:28:14.000Z","dependencies_parsed_at":"2023-01-12T02:45:51.932Z","dependency_job_id":null,"html_url":"https://github.com/cantonjs/wxapp-boilerplate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cantonjs%2Fwxapp-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cantonjs%2Fwxapp-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cantonjs%2Fwxapp-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cantonjs%2Fwxapp-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cantonjs","download_url":"https://codeload.github.com/cantonjs/wxapp-boilerplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247430872,"owners_count":20937874,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alipay","alipay-mini-program","babel","boilerplate","lib-boilerplate","mini-program","scss","weapp","webpack","wechat","wechat-mini-program","wxapp","wxapp-boilerplate"],"created_at":"2024-11-24T16:11:58.217Z","updated_at":"2025-04-06T04:12:14.256Z","avatar_url":"https://github.com/cantonjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wxapp-boilerplate\n\n使用 `webpack`, `babel`, `scss` 开发的微信／支付宝小程序项目脚手架\n\n## 功能\n\n* 支持引用 `node_modules` 模块\n* 支持通过配置 `alias` 来避免 `../../../` 之类的模块引用\n* 通过 `babel` 支持更丰富的 `ES6` 兼容，包括 `async/await`\n* 内置 `promise` 和 `lodash`（`lodash` 按需引入相应模块，不会全部引入）\n* 使用 `scss` 编写 `.wxss` 文件，内置了一些有用的 `mixins` 和 `extends`\n* 提供 `__DEV__` 和 `process.env.NODE_ENV` 全局常量辅助开发\n* 支持自动编译为微信和支付宝小程序\n* 提供 `__WECHAT__` 和 `__ALIPAY__` 全局常量来判断是微信小程序或支付宝小程序\n* 通过命令行快速创建微信小程序页面\n* 支持在 `production` 环境下压缩代码\n\n## 开始使用\n\n确保安装了 [Node.js](https://nodejs.org/) (\u003e= `v4.2`) 和 [yarn](https://yarnpkg.com) 或 [npm](https://www.npmjs.com/package/npm)\n\n1.  `git clone` 此项目\n2.  通过命令行工具 `cd` 到这个目录，执行 `yarn` 安装依赖模块\n3.  执行 `yarn start` 开始开发\n4.  通过微信开发者工具，添加 `dist/wechat` 目录到项目上\n\n## 内置命令\n\n* `yarn start` 启动 `webpack` 开发微信小程序项目，能监听文件变化自动重新编译\n* `yarn start:alipay` 启动 `webpack` 开发支付宝小程序项目，能监听文件变化自动重新编译\n* `yarn build` 编译生成 `production` 环境的代码到 `dist/wechat` 和 `dist/alipay`\n* `yarn lint:build` 执行 `yarn build` 命令，并使用 eslint 和 stylelint 来校验代码规范\n* `yarn prettier` 执行 `prettier` 来格式化 src 目录下的代码\n* `yarn create-page` 快速创建微信小程序页面（更多 `create-page` 的用法，请查看 [create-wxapp-page](https://github.com/cantonjs/create-wxapp-page)）\n\n## 兼容微信和支付宝小程序\n\n开发者可以选择一套源代码来开发微信和支付宝小程序，这脚手架支持自动编译 `wxml` 为 `axml`，转换 `wx:attr` 为 `a:attr`，转换 API `wx` 为 `my`，反之亦然。但个别接口在平台上也略有差异，开发者可以通过 `__WECHAT__` 或 `__ALIPAY__` 来动态处理。\n\n## 文件复制\n\n如果 `wxml` 或 `axml` 有动态引入文件（如 `src=\"{{'images/' + type + '.png'}}\"`），webpack 将不能动态引入，因此会导致打包后可能会存在缺失文件问题。\n\n遇到这种情况，可以通过 [copy-webpack-plugin](https://github.com/webpack-contrib/copy-webpack-plugin) 解决，把整个 `images` 目录复制到 `dist` 下即可。\n\n本脚手架已经内置这个插件。为了方便使用，还可以通过在 `package.json` 里增加一个 `copyWebpack` 的字符串数组，来实现目录或文件自动复制。例如：\n\n**package.json**\n\n```json5\n{\n  // ...\n  \"copyWebpack\": [\"images\", \"icons\"]\n}\n```\n\n通过执行 `yarn start` 或 `yarn build`，`src/images` 和 `src/icons` 目录会自动复制到 `dist/wechat/images` 和 `dist/wechat/icons` 目录（支付宝小程序同理）。\n\n## 更新日志\n\n[Changelog](/CHANGELOG.md)\n\n## 相关项目\n\n* [create-wxapp-page](https://github.com/cantonjs/create-wxapp-page)\n* [react-lib-boilerplate](https://github.com/cantonjs/react-lib-boilerplate)\n* [front-end-lib-boilerplate](https://github.com/cantonjs/front-end-lib-boilerplate)\n* [node-cli-boilerplate](https://github.com/cantonjs/node-cli-boilerplate)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcantonjs%2Fwxapp-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcantonjs%2Fwxapp-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcantonjs%2Fwxapp-boilerplate/lists"}