【发布时间】:2022-01-11 05:55:49
【问题描述】:
您好,我有一个名为 Home 的应用程序,它具有可安装的插件,我可以在任何时间点安装这些插件,这些插件在 iframe 中运行
<Home /home/user/mainprojects/index.html> <-- Home app
<Bed iframe /home/user/plugins/bed/index.html> <-- plugins app
<Bed /iframe>
</Home>
有了这个nginx 设置,我可以在构建后加载插件应用程序(床)(这非常耗时)
这里是 nginx 设置
location / {
alias /home/user/mainprojects/dist/;
index index.html;
}
location /Bed {
alias /home/user/plugins/bed/dist/;
index index.html index.htm;
}
问题:我不想构建主应用程序Home 应用程序我想通过serve 运行它,但我将始终构建第二个应用程序,即插件可用作为捆绑。在构建两者之后使用上述nginx 设置(即npm run build,bundle)它会正常工作。我想避免构建主应用程序。
这是我的vue.config.js 的样子
module.exports = {
devServer:{
proxy:{
'^/appReplacer':{
target: 'http://100.148.1.9:9003/',
changeOrigin:true,
logLevel:'debug',
pathRewrite: {'^/appReplacer':'/'}
}
}
}
}
仍在寻找解决方案..
请帮助我提前谢谢!
【问题讨论】:
-
您应该在 DEV 模式下运行第二个应用程序 - 在地址 100.148.1.9 上侦听端口 9003,因此第一个应用程序将能够将您的请求代理到第二个应用程序。
-
@IVOGELOV,
nginx我也可以通过运行它来加载第二个应用程序(构建后) -
您说您正在寻找没有
nginX的解决方案,因为您想避免捆绑 - 因此您需要在两个应用程序的项目文件夹中运行npm run serve。 -
@IVO GELOV,抱歉不清楚,我的第二个应用程序将始终作为捆绑包提供,但我的第一个应用程序将始终通过
npm run serve -
如果您的应用始终以捆绑包形式提供 - 您将永远无法在此捆绑包上使用
npm run serve。该捆绑包必须通过nginX或类似的HTTP 服务器提供。npm run serve只能处理原始未捆绑的源代码。
标签: vue.js webpack webpack-dev-server vue-cli devserver