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

@nrwl/vite:dev-server HMR doesn't work #13477

Closed
montella1507 opened this issue Nov 29, 2022 · 2 comments
Closed

@nrwl/vite:dev-server HMR doesn't work #13477

montella1507 opened this issue Nov 29, 2022 · 2 comments

Comments

@montella1507
Copy link

Current Behavior

I cannot make the @nrwl/vite:dev-server work with HMR. I tried to set it via project.json:

 "targets": {
    "serve": {
      "executor": "@nrwl/vite:dev-server",
      "defaultConfiguration": "development",
      "options": {
        "buildTarget": "scenario-editor:build",
        "port": 4202,
        "hmr": true,
        "mode": "development"
      },
      "configurations": {

      }
    },

or via vite.config.ts


import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import legacy from '@vitejs/plugin-legacy'
import vue2 from '@vitejs/plugin-vue2'


import { createI18nPlugin } from '@yfwz100/vite-plugin-vue2-i18n';
// https://vitejs.dev/config/
export default defineConfig({
  server: {
    hmr: true,
    port: 4202,
  },
  mode: "development",
  plugins: [

    vue2(),
   createI18nPlugin({}),
    legacy({
      targets: ['ie >= 11'],
      additionalLegacyPolyfills: ['regenerator-runtime/runtime']
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})

However... it doesn't work.

I get this error:

Uncaught TypeError: Cannot read properties of undefined (reading 'accept')
From random component.
image

Seems like that import.hot is not provided correctly?

Expected Behavior

HMR should work correctly.

Github Repo

No response

Steps to Reproduce

  1. I have created empty vite project in NX monorepo
  2. Added vue2() plugin to vue.config.ts
  3. nx run project:serve

Nx Report

nx : 14.8.3
   @nrwl/angular : 14.8.3
   @nrwl/cypress : 15.2.1
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.2.1
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 14.8.3
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.2.1
   @nrwl/js : 15.2.1
   @nrwl/linter : 14.8.3
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : 14.7.0
   @nrwl/nx-plugin : 15.2.1
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/rollup : 15.2.1
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.8.4
   @nrwl/web : 15.2.1
   @nrwl/webpack : 14.8.3
   @nrwl/workspace : 14.8.3
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
         @smartemailing/vue (NOT USED ATM)
   ---------------------------------------
   Community plugins:
         @nrwl/vite: 15.2.1
         @nx-plus/vue: 14.1.0   (NOT USED ANYMORE) 
         @storybook/angular: 6.5.12

Failure Logs

No response

Additional Information

No response

@montella1507
Copy link
Author

Problem of Vue plugin

vitejs/vite-plugin-vue2#69

Workaround mentioned in issue solves the problem.

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant