File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,19 +54,31 @@ yarn add -D wxapp-webpack-plugin
5454
5555## API
5656
57- ` new WXAppWebpackPlugin(options) `
57+ #### ` new WXAppWebpackPlugin(options) `
5858
5959###### options
6060
6161- ` clear ` (Boolean): 在启动 ` webpack ` 时清空 ` dist ` 目录。默认为 ` true `
6262- ` commonModuleName ` (String): 公共 ` js ` 文件名。默认为 ` common.js `
63- - ` global ` (String): 全局对象名。在微信小程序上,该值应该为 ` wx ` ,在支付宝小程序上,该值应该为 ` my ` 。默认为 ` wx `
6463
64+ #### ` Targets `
65+
66+ Webpack target 值,目前有 ` Targets.Wechat ` 和 ` Targets.Alipay ` ,如果不配置,webpack target 将会自动设为 ` Targets.Wechat ` 。如果需要开发支付宝小程序,则改为 ` Targets.Alipay ` 开发者可以通过 ` process.env.TARGET ` 之类的配置来动态输出。
67+
68+ ###### Example
69+
70+ ``` js
71+ import WXAppWebpackPlugin , { Targets } from ' wxapp-webpack-plugin' ;
72+
73+ export default {
74+ // ...configs,
75+ target: Targets[process .env .TARGET || ' Wechat' ],
76+ };
77+ ```
6578
6679## 提示
6780
6881- 程序的开发方式与 [ 微信小程序开发文档] ( https://mp.weixin.qq.com/debug/wxadoc/dev/ ) 一样,开发者需要在 ` src ` (源)目录创建 ` app.js ` 、` app.json ` 、` app.wxss ` 、` pages/index/index.js ` 之类的文件进行开发
69- - 如果需要用 ` wxapp-webpack-plugin ` 来开发支付宝小程序,那么需要在确保在 ` options ` 上配置 ` { global: "my" } `
7082
7183
7284## License
You can’t perform that action at this time.
0 commit comments