diff --git a/src/index.ts b/src/index.ts index a06dd2efc..35ab5a2b5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -41,6 +41,7 @@ export interface VueLoaderOptions { hotReload?: boolean exposeFilename?: boolean appendExtension?: boolean + enableServerHMR?: boolean } let errorEmitted = false @@ -84,6 +85,7 @@ export default function loader( {}) as VueLoaderOptions const isServer = target === 'node' + const enableServerHMR = options.enableServerHMR const isProduction = mode === 'production' const { descriptor, errors } = parse(source, { @@ -121,7 +123,7 @@ export default function loader( // feature information const hasScoped = descriptor.styles.some((s) => s.scoped) const needsHotReload = - !isServer && + (enableServerHMR || !isServer) && !isProduction && !!(descriptor.script || descriptor.template) && options.hotReload !== false