
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
webpack-wxapp-module-plugin
Advanced tools
微信小程序webapck插件
entry 指向app.js即可 例如 entry:'./app.js'node_modules 模块引用node_modules 组件引用node_modules平行移植 打包后的require会自动修改引用路径 例如: require('lodash') 那么当打包后在dist下的引用变为 require('./node_modules/lodash/inde.jx)loaders与其他plugin使支持es6-es7以及文件图片压缩dist(webpack设定的output目录)目录即可npm install webpack-wxapp-module-plugin --save-dev
Webpack 简单配置
var WxappModulePlugin =require('webpack-wxapp-module-plugin');
var appjsRoot = path.resolve('');
module.exports = {
context:appjsRoot,
entry: {
'app': ['./app.js']
},
output: {
filename: '[name]',
chunkFilename:'[name]',
libraryTarget: 'commonjs2'
},
plugins:[
new WxappModulePlugin({
// 构建后node_modules下模块存放目录名
nodeModulesName: 'npm_modules',
// 当前运行模式: plugin / miniprogram 默认为 miniprogram
// mode: 'plugin',
// 插件模式下,插件代码根目录
// pluginRoot: path.resolve('packages/mp-stjk-plugin'),
// 全局组件
globalComponents:{
// 'layout-master':'my/index'
}
// 支持额外的资源扩展名,例如支持index.scss
resolveExtensions: [
'.scss',
// 或者 (id)=> id + '.scss'
],
}),
],
module:{
rules:[
// wxs
{
test: /\.wxs$/,
use: [
{
loader: 'file-loader',
options: {
name: '[path][name].wxml',
esModule: false,
},
},
'webpack-wxapp-module-plugin/wxs-loader',
],
},
// wxml
{
test: /\.wxml$/,
use: [
{
loader: 'file-loader',
options: {
name: '[path][name].wxml',
esModule: false,
},
},
'webpack-wxapp-module-plugin/wxml-loader',
{
// 母版页支持, 即:可以定义一个app.wxml 或者定义一个组件包裹在所有页面组件
loader: 'webpack-wxapp-module-plugin/layout-loader',
options:{
// 组件模式支持,
// component:'master-layout'
}
},
],
},
]
}
}
在部分情况下,我们需要引用小程序UI组件库,那么通常依赖是安装在node_modules下,
webpack-wxapp-module-plugin 提供了node_modules下组件引用,例如:
{
"usingComponents":{
"i-button":"iview-weapp/dist/button"
}
}
基于 MIT License 开源,使用代码只需说明来源,或者引用 license.txt 即可。
FAQs
[![NPM version][npm-image]][npm-url]
The npm package webpack-wxapp-module-plugin receives a total of 16 weekly downloads. As such, webpack-wxapp-module-plugin popularity was classified as not popular.
We found that webpack-wxapp-module-plugin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.