Ale*_*nko 29 vue.js vuejs2 vue-cli
我想构建两个独立的vue应用程序,这些应用程序将在快速应用程序中的两个不同路由上提供:"公共"vue应用程序和"admin"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
+- ...
Run Code Online (Sandbox Code Playgroud)
必须由可用的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()
}
}
Run Code Online (Sandbox Code Playgroud)
Kam*_*han 18
假设您需要完全独立的构建,并以条目为指导使用一些共享脚本,则可以添加独立的构建命令。
在您的package.json“脚本”部分中:
"scripts": {
"build:admin": "vue-cli-service build --dest dist/admin src/admin/index.js,
"build:public": "vue-cli-service build --dest dist/public src/public/index.js
}
Run Code Online (Sandbox Code Playgroud)
对于管理员版本,您可以运行:
npm run build:admin
Run Code Online (Sandbox Code Playgroud)
对于公共建筑:
npm run build:public
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请查看构建目标文档。
Luc*_*vet 14
我对此事也很感兴趣.
也许我们可以用子页面来解决这个问题:
https://cli.vuejs.org/config/#pages:"以多页模式构建应用程序.每个"页面"应该有一个相应的JavaScript条目文件.该值应该是一个对象,其中键是名称条目,值是:"
module.exports = {
pages: {
index: {
// entry for the *public* page
entry: 'src/index/main.js',
// the source template
template: 'public/index.html',
// output as dist/index.html
filename: 'index.html'
},
// an admin subpage
// when using the entry-only string format,
// template is inferred to be `public/subpage.html`
// and falls back to `public/index.html` if not found.
// Output filename is inferred to be `admin.html`.
admin: 'src/admin/main.js'
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9091 次 |
| 最近记录: |