How to use it in iis or nginx after build? #6155
Answered
by
xc2
AlbertXiaoPeng
asked this question in
Q&A
-
I referenced #5501 for the build setup. modern.config.ts import { appTools, defineConfig } from '@modern-js/app-tools';
import { tailwindcssPlugin } from '@modern-js/plugin-tailwindcss';
// https://modernjs.dev/en/configure/app/usage
export default defineConfig({
output: {
cleanDistPath: true,
distPath: {
html: '',
},
},
server: {
baseUrl: '/test',
},
runtime: {
router: true,
},
html: {
favicon: './src/assets/favicon.svg',
disableHtmlFolder: true,
},
source: {
mainEntryName: 'index',
},
plugins: [
appTools({
bundler: 'experimental-rspack', // Set to 'experimental-rspack' to enable rspack ⚡️🦀
}),
tailwindcssPlugin(),
],
}); I added web.config to the dist directory <?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301880
-->
<configuration>
<system.webServer>
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/test/" responseMode="ExecuteURL" />
</httpErrors>
<staticContent>
<remove fileExtension=".html" />
<mimeMap fileExtension=".html" mimeType="text/html; charset=UTF-8" />
</staticContent>
</system.webServer>
</configuration> Performed iis site configuration However, when accessing it, the index.html file is displayed without any problem, but the static file is inaccessible, I think it is because the corresponding path was not configured when generating the file. How to deal with it? |
Beta Was this translation helpful? Give feedback.
Answered by
xc2
Sep 2, 2024
Replies: 1 comment 1 reply
-
modern.config.tsset web.config<?xml version="1.0"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Static Site" 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>
</rules>
</rewrite>
</system.webServer>
</configuration> if it doesn't work, please try changing the |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
AlbertXiaoPeng
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
modern.config.ts
set
output.assetPrefix
to/test/
web.config
if it doesn't work, please try changing the
Rewrite
url from/
to/test/
.