Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Commit

Permalink
fix: don't inject hmr code in SSR (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
galvez authored Jan 3, 2022
1 parent ee1ff2e commit d84ffec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export function createVuePlugin(rawOptions: VueViteOptions = {}): Plugin {
}
},

async transform(code, id) {
async transform(code, id, transformOptions) {
const { filename, query } = parseVueRequest(id)

if (/\.(tsx|jsx)$/.test(id)) {
Expand All @@ -152,7 +152,7 @@ export function createVuePlugin(rawOptions: VueViteOptions = {}): Plugin {

if (!query.vue) {
// main request
return await transformMain(code, filename, options, this)
return await transformMain(code, filename, options, transformOptions, this)
}

const descriptor = getDescriptor(
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export async function transformMain(
code: string,
filePath: string,
options: ResolvedOptions,
transformOptions: any,
pluginContext: TransformPluginContext
) {
const descriptor = createDescriptor(code, filePath, options)
Expand Down Expand Up @@ -86,7 +87,7 @@ function __vue2_injectStyles (context) {
// code += `\n__component__.options.__file = ${JSON.stringify(filePath)}`
// }

if (options.devServer && !options.isProduction) {
if (!transformOptions.ssr && options.devServer && !options.isProduction) {
result += genHmrCode(
options.root,
descriptor.id,
Expand Down

0 comments on commit d84ffec

Please sign in to comment.