Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugin-vue): respect hmr: false server config #2797

Merged
merged 1 commit into from Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/plugin-vue/src/main.ts
Expand Up @@ -114,7 +114,12 @@ export async function transformMain(
output.push('export default _sfc_main')

// HMR
if (devServer && !ssr && !isProduction) {
if (
devServer &&
devServer.config.server.hmr !== false &&
!ssr &&
!isProduction
) {
output.push(`_sfc_main.__hmrId = ${JSON.stringify(descriptor.id)}`)
output.push(
`typeof __VUE_HMR_RUNTIME__ !== 'undefined' && ` +
Expand Down
7 changes: 6 additions & 1 deletion packages/plugin-vue/src/template.ts
Expand Up @@ -20,7 +20,12 @@ export function transformTemplateAsModule(
const result = compile(code, descriptor, options, pluginContext, ssr)

let returnCode = result.code
if (options.devServer && !ssr && !options.isProduction) {
if (
options.devServer &&
options.devServer.config.server.hmr !== false &&
!ssr &&
!options.isProduction
) {
returnCode += `\nimport.meta.hot.accept(({ render }) => {
__VUE_HMR_RUNTIME__.rerender(${JSON.stringify(descriptor.id)}, render)
})`
Expand Down