【发布时间】:2018-09-02 09:48:25
【问题描述】:
我想构建两个独立的 vue 应用程序,它们将在一个 express 应用程序中的两条不同路线上提供服务:一个“公共”vue 应用程序和一个“管理员”vue 应用程序。这两个应用程序有自己的路由器和存储,但它们共享许多自定义组件。 如何编辑默认的 webpack 模板,使其根据我的两个不同入口点(“public”和“admin”)输出两个单独的包? 我们的目标是最终得到或多或少这样的设置:
my-app/
+- ...
+- dist/
| +- admin/ Admin bundle and files
| +- public/ Public bundle and files
+- src/
| +- components/ Shared components
| +- admin/ Entry point, router, store... for the admin app
| +- public/ Entry point, router, store... for the public app
+- ...
必须有两个可用的开发服务器 http://localhost:8080/admin 和 http://localhost:8080/public 每个项目必须在 dist 中自己的文件夹中,并且拥有 public
我今天有什么: 在根目录创建文件 vue.config.js 与:
module.exports = {
// tweak internal webpack configuration.
// see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
chainWebpack: config => {
// If you wish to remove the standard entry point
config.entryPoints.delete('app')
// then add your own
config.entry('admin')
.add('./src/admin/index.js')
.end()
.entry('public')
.add('./src/public/index.js')
.end()
}
}
【问题讨论】:
-
每个人都有解决方案吗?