mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
feat(webpack, vite): default to .js
extension for client (#6505)
This commit is contained in:
parent
3960f513c3
commit
0a513a56b1
@ -122,8 +122,8 @@ export default {
|
||||
* ```
|
||||
*/
|
||||
filenames: {
|
||||
app: ({ isDev }) => isDev ? `[name].mjs` : `[contenthash:7].mjs`,
|
||||
chunk: ({ isDev }) => isDev ? `[name].mjs` : `[contenthash:7].mjs`,
|
||||
app: ({ isDev }) => isDev ? `[name].js` : `[contenthash:7].js`,
|
||||
chunk: ({ isDev }) => isDev ? `[name].js` : `[contenthash:7].js`,
|
||||
css: ({ isDev }) => isDev ? '[name].css' : 'css/[contenthash:7].css',
|
||||
img: ({ isDev }) => isDev ? '[path][name].[ext]' : 'img/[name].[contenthash:7].[ext]',
|
||||
font: ({ isDev }) => isDev ? '[path][name].[ext]' : 'fonts/[name].[contenthash:7].[ext]',
|
||||
|
@ -37,14 +37,6 @@ export async function buildClient (ctx: ViteBuildContext) {
|
||||
}
|
||||
},
|
||||
build: {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
// https://github.com/vitejs/vite/tree/main/packages/vite/src/node/build.ts#L464-L478
|
||||
assetFileNames: ctx.nuxt.options.dev ? undefined : withoutLeadingSlash(join(ctx.nuxt.options.app.buildAssetsDir, '[name].[hash].[ext]')),
|
||||
chunkFileNames: ctx.nuxt.options.dev ? undefined : withoutLeadingSlash(join(ctx.nuxt.options.app.buildAssetsDir, '[name].[hash].mjs')),
|
||||
entryFileNames: ctx.nuxt.options.dev ? 'entry.mjs' : withoutLeadingSlash(join(ctx.nuxt.options.app.buildAssetsDir, '[name].[hash].mjs'))
|
||||
}
|
||||
},
|
||||
manifest: true,
|
||||
outDir: resolve(ctx.nuxt.options.buildDir, 'dist/client')
|
||||
},
|
||||
@ -72,6 +64,16 @@ export async function buildClient (ctx: ViteBuildContext) {
|
||||
clientConfig.server.hmr = false
|
||||
}
|
||||
|
||||
// We want to respect users' own rollup output options
|
||||
ctx.config.build.rollupOptions = defu(ctx.config.build.rollupOptions, {
|
||||
output: {
|
||||
// https://github.com/vitejs/vite/tree/main/packages/vite/src/node/build.ts#L464-L478
|
||||
assetFileNames: ctx.nuxt.options.dev ? undefined : withoutLeadingSlash(join(ctx.nuxt.options.app.buildAssetsDir, '[name].[hash].[ext]')),
|
||||
chunkFileNames: ctx.nuxt.options.dev ? undefined : withoutLeadingSlash(join(ctx.nuxt.options.app.buildAssetsDir, '[name].[hash].js')),
|
||||
entryFileNames: ctx.nuxt.options.dev ? 'entry.js' : withoutLeadingSlash(join(ctx.nuxt.options.app.buildAssetsDir, '[name].[hash].js'))
|
||||
}
|
||||
})
|
||||
|
||||
if (clientConfig.server.hmr !== false) {
|
||||
const hmrPortDefault = 24678 // Vite's default HMR port
|
||||
const hmrPort = await getPort({
|
||||
|
Loading…
Reference in New Issue
Block a user