packageD里面是分包的代码,发行成飞书小程序之后,里面的代码还是微信小程序代码?
// vue.config.js
class CopyOriginSubPackagePlugin {
constructor(subPackagesOptions = {}) {
// 微信原生的分包配置规则
this.subPackagesOptions = subPackagesOptions
}
apply(compiler) {
const that = this
compiler.hooks.emit.tap('CopyOriginSubPackage', (compilation) => {
// 找到app.json文件
const appJsonAssets = compilation.assets['app.json']
if (!appJsonAssets) {
return
}
try {
// app.json文件内容转成json格式
const source = JSON.parse(appJsonAssets.source())
// 添加一个默认的subPackages
const subPackages = (source.subPackages = source.subPackages || [])
// 把要集成的分包添加到app.json中
subPackages.push(that.subPackagesOptions)
// 将修改后的内容写入到文件中
const fileContent = JSON.stringify(source, null, 2)
compilation.assets['app.json'] = {
source() {
return fileContent
},
size() {
return fileContent.length
}
}
} catch (e) {
console.log('[CopyOriginSubPackagePlugins Error]', e)
}
})
}
}
const plugins = []
if (process.env.UNI_PLATFORM === 'mp-weixin' || process.env.UNI_PLATFORM === 'mp-lark') {
plugins.push(
new CopyWebpackPlugin([
{
from: path.join(__dirname, 'packageD'),
to: path.join(__dirname, 'unpackage/dist', process.env.NODE_ENV === 'production' ? 'build' : 'dev', process.env.UNI_PLATFORM, 'packageD')
}
]),
// 配置分包页面路由
new CopyOriginSubPackagePlugin({
root: 'packageD',
pages: [
"pages/index/index",