我希望构建两个独立的Vue应用,这些应用将在Express应用程序的两个不同路由上提供:一个“公共”Vue应用和一个“管理员”Vue应用。这两个应用都有自己的路由器和存储,但它们共享许多自定义组件。 如何编辑默认的Webpack模板以根据我的两个不同入口点(“公共”和“管理员”)生成两个单独的包? 目标是最终获得类似于以下设置:
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
+- ...
必须提供2个开发服务器 http://localhost:8080/admin 和 http://localhost:8080/public 每个项目必须在dist中拥有自己的文件夹和公共文件夹
我今天的工作内容: 在根目录创建了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()
}
}