wxapp-webpack-plugin has 17 recorded weekly downloads on npm, a decrease of 63.8% over the past 30 days.
It ranks #1853 of 2,251 tracked npm listings by weekly downloads.
Over 90 days, weekly downloads changed by -32.0%.
PluginStats has 121 daily observations since Jun 19, 2026; the latest is from Oct 17, 2026.
About wxapp-webpack-plugin
wxapp-webpack-plugin
微信小程序 webpack 插件
为什么要使用 webpack
很多前端开发者都使用过 webpack,通过 webpack 开发 JavaScript 项目可以带来很多好处
• 支持通过 yarn 或 npm 引入和使用 node_modules 模块 • 支持丰富且灵活的 loaders 和 plugins • 支持 alias • 还有很多...
为什么要使用这个插件
• 微信小程序开发需要有多个入口文件(如 app.js, app.json, pages/index/index.js 等等),使用这个插件只需要引入 app.js 即可,其余文件将会被自动引入 • 若多个入口文件(如 pages/index/index.js 和 pages/logs/logs.js)引入有相同的模块,这个插件能避免重复打包相同模块 • 支持自动复制 app.json 上的 tabbar 图片 (v0.17.0 或以上)
使用方法
安装
配置 webpack
1. 在 entry 上引入 { app: './src/app.js' }, 这里的 ./src/app.js 为微信小程序开发所需的 app.js。注意 key 必须为 app,value 支持数组)
2. 在 output 上设置 filename: '[name].js'。 注意 这里 [name].js 是因为 webpack 将会打包生成多个文件,文件名称将以 [name] 规则来输出
3. 添加 new WXAppWebpackPlugin() 到 plugins
loader 的使用提示
为了使 webpack 能编译和输出非 .js 文件,配置时要按需添加各种 loaders。这里作者推荐使用以下几个对微信小程序开发很有用的 loaders:
• file-loader: 用于输出 *.json,*.wxss,*.jpg 之类的文件 • css-loader: 使 webpack 能编译或处理 *.wxss 上引用的文件 • wxml-loader: 使 webpack 能编译或处理 *.wxml 上引用的文件
开发者也可以根据自身需求和习惯,使用 sass-loader 之类的 loader。
完整的项目开发脚手架,请查看 wxapp-boilerplate
API
WXAppWebpackPlugin
用法
webpack.config.babel.js
Options
所有 Options 均为可选
• clear (\): 在启动 webpack 时清空 dist 目录。默认为 true • commonModuleName (\): 公共 js 文件名。默认为 common.js • extensions (\\>): 脚本文件后缀名。默认为 ['.js']
Targets
Webpack target 值,目前有 Targets.Wechat 和 Targets.Alipay,如果不配置,webpack target 将会自动设为 Targets.Wechat。如果需要开发支付宝小程序,则改为 Targets.Alipay。开发者也可以通过 process.env.TARGET 之类的配置来动态输出。
示例
webpack.config.babel.js
提示
• 程序的开发方式与 微信小程序开发文档 一样,开发者需要在 src (源)目录创建 app.js、app.json、app.wxss、pages/index/index.js 之类的文件进行开发
License
MIT © Cap32
Description from the npm listing.
- wxapp
- weapp
- webpack
- webpack-plugin
- plugin
Where wxapp-webpack-plugin sits in the listing
Each band is one page of 20. Weekly downloads on a log scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Recent observations
Full history (121)Similar npm Webpack plugins plugins
Data source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/wxapp-webpack-plugin. First seen Oct 16, 2026; last successful collection Oct 18, 2026. See the methodology.