mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +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 }}>
|
<body {{ BODY_ATTRS }}>
|
||||||
{{ APP }}
|
{{ APP }}
|
||||||
<% if (nuxt.options.vite && nuxt.options.dev) { %><script type="module" src="/@vite/client"></script>
|
<% 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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -28,7 +28,7 @@ export async function buildServer (ctx: ViteBuildContext) {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
outDir: 'dist/server',
|
outDir: resolve(ctx.nuxt.options.buildDir, 'dist/server'),
|
||||||
ssr: true,
|
ssr: true,
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
input: resolve(ctx.nuxt.options.buildDir, 'entry.mjs'),
|
input: resolve(ctx.nuxt.options.buildDir, 'entry.mjs'),
|
||||||
|
@ -23,7 +23,7 @@ export async function bundle (nuxt: Nuxt) {
|
|||||||
config: vite.mergeConfig(
|
config: vite.mergeConfig(
|
||||||
nuxt.options.vite as any || {},
|
nuxt.options.vite as any || {},
|
||||||
{
|
{
|
||||||
root: nuxt.options.buildDir,
|
root: nuxt.options.rootDir,
|
||||||
mode: nuxt.options.dev ? 'development' : 'production',
|
mode: nuxt.options.dev ? 'development' : 'production',
|
||||||
logLevel: 'warn',
|
logLevel: 'warn',
|
||||||
define: {
|
define: {
|
||||||
@ -35,6 +35,7 @@ export async function bundle (nuxt: Nuxt) {
|
|||||||
...nuxt.options.alias,
|
...nuxt.options.alias,
|
||||||
'#build': nuxt.options.buildDir,
|
'#build': nuxt.options.buildDir,
|
||||||
'#app': nuxt.options.appDir,
|
'#app': nuxt.options.appDir,
|
||||||
|
'/__build': nuxt.options.buildDir,
|
||||||
'~': nuxt.options.srcDir,
|
'~': nuxt.options.srcDir,
|
||||||
'@': nuxt.options.srcDir,
|
'@': nuxt.options.srcDir,
|
||||||
'web-streams-polyfill/ponyfill/es2018': 'unenv/runtime/mock/empty',
|
'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) => {
|
nuxt.hook('vite:serverCreated', (server: vite.ViteDevServer) => {
|
||||||
const start = Date.now()
|
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`)
|
consola.info(`Vite warmed up in ${Date.now() - start}ms`)
|
||||||
}).catch(consola.error)
|
}).catch(consola.error)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user