提交 979b0c29 编写于 作者: D DCloud_LXH

chore(mp): 小程序导出到插件

上级 c265a947
......@@ -25,14 +25,12 @@ module.exports = {
copyOptions.push('uni_modules/' + module + '/mycomponents')
})
JSON.parse(process.env.UNI_MP_PLUGIN_EXPORT)
.concat(process.env.UNI_MP_PLUGIN ? 'plugin.json' : undefined)
.forEach(fileName => {
fileName && copyOptions.push({
from: path.resolve(process.env.UNI_INPUT_DIR, fileName),
transform: content => fileName === 'plugin.json' ? JSON.stringify(parseJson(content.toString(), true)) : content
})
if (process.env.UNI_MP_PLUGIN) {
copyOptions.push({
from: path.resolve(process.env.UNI_INPUT_DIR, 'plugin.json'),
transform: content => JSON.stringify(parseJson(content.toString(), true))
})
}
return copyOptions
}
......
......@@ -32,14 +32,12 @@ module.exports = {
'functional-pages'
]
JSON.parse(process.env.UNI_MP_PLUGIN_EXPORT)
.concat(process.env.UNI_MP_PLUGIN ? 'plugin.json' : undefined)
.forEach(fileName => {
fileName && copyOptions.push({
from: path.resolve(process.env.UNI_INPUT_DIR, fileName),
transform: content => fileName === 'plugin.json' ? JSON.stringify(parseJson(content.toString(), true)) : content
})
if (process.env.UNI_MP_PLUGIN) {
copyOptions.push({
from: path.resolve(process.env.UNI_INPUT_DIR, 'plugin.json'),
transform: content => JSON.stringify(parseJson(content.toString(), true))
})
}
const workers = platformOptions.workers
workers && copyOptions.push(workers)
......
......@@ -177,19 +177,11 @@ module.exports = {
{
const globalEnv = process.env.UNI_PLATFORM === 'mp-alipay' ? 'my' : 'wx'
if (process.env.UNI_MP_PLUGIN) {
// 小程序插件入口使用
// packages\webpack-uni-mp-loader\lib\plugin\index-new.js -> addMPPluginRequire
addToUniEntry(process.env.UNI_MP_PLUGIN_MAIN)
beforeCode += `${globalEnv}.__webpack_require_${process.env.UNI_MP_PLUGIN.replace(/-/g, '_')}__ = __webpack_require__;`
} else {
beforeCode += `${globalEnv}.__webpack_require_UNI_MP_PLUGIN__ = __webpack_require__;`
}
;[].concat(process.env.UNI_MP_PLUGIN ? process.env.UNI_MP_PLUGIN_MAIN : JSON.parse(process.env.UNI_MP_PLUGIN_EXPORT))
.forEach(fileName => addToUniEntry(fileName))
beforeCode += `${globalEnv}.__webpack_require_${(process.env.UNI_MP_PLUGIN || 'UNI_MP_PLUGIN').replace(/-/g, '_')}__ = __webpack_require__;`
}
JSON.parse(process.env.UNI_MP_PLUGIN_EXPORT).forEach(fileName => addToUniEntry(fileName))
const alias = { // 仅 mp-weixin
'mpvue-page-factory': require.resolve(
'@dcloudio/vue-cli-plugin-uni/packages/mpvue-page-factory')
......
......@@ -71,7 +71,8 @@ function addMPPluginRequire (compilation) {
const UNI_MP_PLUGIN_MAIN = process.env.UNI_MP_PLUGIN_MAIN
const UNI_MP_PLUGIN_EXPORT = JSON.parse(process.env.UNI_MP_PLUGIN_EXPORT)
assetsKeys.forEach(name => {
if ((name === UNI_MP_PLUGIN_MAIN && process.env.UNI_MP_PLUGIN) || UNI_MP_PLUGIN_EXPORT.includes(name)) {
const needProcess = process.env.UNI_MP_PLUGIN ? name === UNI_MP_PLUGIN_MAIN : UNI_MP_PLUGIN_EXPORT.includes(name)
if (needProcess) {
const modules = compilation.modules
const filePath = normalizePath(path.resolve(process.env.UNI_INPUT_DIR, name))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册