【发布时间】:2019-04-20 19:08:26
【问题描述】:
我已将 CLI 生成的 Vue 应用程序与 ASP.NET Core Web 应用程序相结合。
我想创建一个新入口点并在 MVC 视图中使用这个新入口点,同时不影响现有的 main.js 入口点。
我正在使用下面的 vue.config.js 文件来添加第二个入口点。
//https://cli.vuejs.org/config/#pages
module.exports = {
pages: {
index: {
// entry for the page
entry: 'src/main.js',
// the source template
template: 'public/index.html',
// output as dist/index.html
filename: 'index.html',
// when using title option,
// template title tag needs to be <title><%= htmlWebpackPlugin.options.title %></title>
title: 'Index Page',
// chunks to include on this page, by default includes
// extracted common chunks and vendor chunks.
chunks: ['chunk-vendors', 'chunk-common', 'index']
},
index2: {
// entry for the page
entry: 'src/index2.js',
// the source template
template: 'public/index2.html',
// output as dist/index.html
filename: 'index2.html',
// when using title option,
// template title tag needs to be <title><%= htmlWebpackPlugin.options.title %></title>
title: 'Index2 Page',
// chunks to include on this page, by default includes
// extracted common chunks and vendor chunks.
chunks: ['chunk-vendors', 'chunk-common', 'index2']
},
// 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 `subpage.html`.
//subpage: 'src/subpage/main.js'
}
}
在 Views/Index.cshtml 中,当生成的文件包含哈希时,我如何引用必要的文件。即我需要引用 index2.24ba2458.js 和 chunk-vendors.869468b2.js (以及 css 文件)
我可以将 index2.html 的输出目录重定向到 /Views/Home/Index2.cshtml 吗?
我可以将 HMR js 提供给 mvc 视图吗?
【问题讨论】:
-
嘿,我也有类似的设置,你找到解决这个问题的方法了吗?
标签: asp.net-mvc vue.js vue-cli-3