提交 5fa1c600 编写于 作者: D DCloud_LXH

fix(mp-plugin): addMPPluginRequire

上级 7b5a17f4
......@@ -80,12 +80,8 @@ function addMPPluginRequire (compilation) {
const globalEnv = process.env.UNI_PLATFORM === 'mp-alipay' ? 'my' : 'wx'
const filePath = normalizePath(path.resolve(process.env.UNI_INPUT_DIR, name))
const uniModuleId = modules.find(module => module.resource && normalizePath(module.resource) === filePath).id
const newlineIndex = orignalSource.lastIndexOf('\n')
const source =
orignalSource.substring(0, newlineIndex) +
`\nmodule.exports = ${globalEnv}.__webpack_require_UNI_MP_PLUGIN__('${uniModuleId}');\n` +
orignalSource.substring(newlineIndex + 1)
const source = orignalSource + `\nmodule.exports = ${globalEnv}.__webpack_require_UNI_MP_PLUGIN__('${uniModuleId}');\n`
compilation.assets[name] = {
size () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册