运行 IIS 上的 Vue cli 多页面
running Vue cli multi pages on IIS
我已经使用 vue-cli 3 多页面配置将我的 vue 项目设置为有 2 个不同的页面,它在我的开发环境中运行良好(使用历史模式)
现在我正尝试在 IIS 上部署该应用程序,但它无法正常工作。文档中没有关于如何设置的任何内容,我想知道这里是否有人可以提供帮助?
我猜我必须添加第二个 IIS url 重写规则以将请求引导到正确的页面,但我无法让它工作。
<rule name="Go to Dashboard" stopProcessing="true">
<match url="(.*\/bd\/?.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/Dashboard/index.html" />
</rule>
<rule name="Handle History Mode and custom 404/500" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
我想我明白了。
<rule name="Go to Dashboard" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_URI}" pattern="(.*\/bd\/?.*)" negate="false" />
</conditions>
<action type="Rewrite" url="/Dashboard/" />
</rule>
<rule name="Handle History Mode and custom 404/500" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="(.*\/bd\/?.*)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
在 header
中正确使用 vue 配置中的单独模板也很重要
pages: {
index: {
entry: 'src/Landing/main.js',
template: 'public/index.html',
filename: 'index.html',
title: 'Index Page',
chunks: ['chunk-vendors', 'chunk-common', 'index']
},
dashboard: {
entry: 'src/Dashboard/main.js',
template: 'public/bd.html',
filename: 'Dashboard/index.html',
title: 'Dashboard',
chunks: ['chunk-vendors', 'chunk-common', 'dashboard']
},
},
我已经使用 vue-cli 3 多页面配置将我的 vue 项目设置为有 2 个不同的页面,它在我的开发环境中运行良好(使用历史模式)
现在我正尝试在 IIS 上部署该应用程序,但它无法正常工作。文档中没有关于如何设置的任何内容,我想知道这里是否有人可以提供帮助?
我猜我必须添加第二个 IIS url 重写规则以将请求引导到正确的页面,但我无法让它工作。
<rule name="Go to Dashboard" stopProcessing="true">
<match url="(.*\/bd\/?.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/Dashboard/index.html" />
</rule>
<rule name="Handle History Mode and custom 404/500" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
我想我明白了。
<rule name="Go to Dashboard" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_URI}" pattern="(.*\/bd\/?.*)" negate="false" />
</conditions>
<action type="Rewrite" url="/Dashboard/" />
</rule>
<rule name="Handle History Mode and custom 404/500" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="(.*\/bd\/?.*)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
在 header
中正确使用 vue 配置中的单独模板也很重要 pages: {
index: {
entry: 'src/Landing/main.js',
template: 'public/index.html',
filename: 'index.html',
title: 'Index Page',
chunks: ['chunk-vendors', 'chunk-common', 'index']
},
dashboard: {
entry: 'src/Dashboard/main.js',
template: 'public/bd.html',
filename: 'Dashboard/index.html',
title: 'Dashboard',
chunks: ['chunk-vendors', 'chunk-common', 'dashboard']
},
},