mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
fix(vite): set vite's root to current directory (#239)
This commit is contained in:
parent
9e8b042bad
commit
d995e83a31
@ -6,6 +6,6 @@
|
||||
<body {{ BODY_ATTRS }}>
|
||||
{{ APP }}
|
||||
<% if (nuxt.options.vite && nuxt.options.dev) { %><script type="module" src="/@vite/client"></script>
|
||||
<script type="module" src="/entry.mjs"></script><% } %>
|
||||
<script type="module" src="/__build/entry.mjs"></script><% } %>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -28,7 +28,7 @@ export async function buildServer (ctx: ViteBuildContext) {
|
||||
]
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist/server',
|
||||
outDir: resolve(ctx.nuxt.options.buildDir, 'dist/server'),
|
||||
ssr: true,
|
||||
rollupOptions: {
|
||||
input: resolve(ctx.nuxt.options.buildDir, 'entry.mjs'),
|
||||
|
@ -23,7 +23,7 @@ export async function bundle (nuxt: Nuxt) {
|
||||
config: vite.mergeConfig(
|
||||
nuxt.options.vite as any || {},
|
||||
{
|
||||
root: nuxt.options.buildDir,
|
||||
root: nuxt.options.rootDir,
|
||||
mode: nuxt.options.dev ? 'development' : 'production',
|
||||
logLevel: 'warn',
|
||||
define: {
|
||||
@ -35,6 +35,7 @@ export async function bundle (nuxt: Nuxt) {
|
||||
...nuxt.options.alias,
|
||||
'#build': nuxt.options.buildDir,
|
||||
'#app': nuxt.options.appDir,
|
||||
'/__build': nuxt.options.buildDir,
|
||||
'~': nuxt.options.srcDir,
|
||||
'@': nuxt.options.srcDir,
|
||||
'web-streams-polyfill/ponyfill/es2018': 'unenv/runtime/mock/empty',
|
||||
@ -76,7 +77,7 @@ export async function bundle (nuxt: Nuxt) {
|
||||
|
||||
nuxt.hook('vite:serverCreated', (server: vite.ViteDevServer) => {
|
||||
const start = Date.now()
|
||||
warmupViteServer(server, ['/entry.mjs']).then(() => {
|
||||
warmupViteServer(server, [`/@fs${nuxt.options.buildDir.replace(/\\/g, '/')}/entry.mjs`]).then(() => {
|
||||
consola.info(`Vite warmed up in ${Date.now() - start}ms`)
|
||||
}).catch(consola.error)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user