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

feat(nuxt): add watch option and refactor dev server restarting #19530

Merged
merged 4 commits into from Mar 9, 2023

Conversation

danielroe
Copy link
Member

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This provides a number of improvements to the dev server restarting behaviour:

  1. it allows configuring the files that cause a server restart (with either string/RegExp - more complex patterns can be handled with builder:watch hook
  2. it fixes implementation detail where we were only listening in dev server to rootDir changes, but we were trying to match against srcDir - this would have worked unless there was a custom srcDir (an undetected bug?)
  3. it now offers more precise matching in pages module to detect changes and trigger restart
  4. we now support restarting on actual component/composables/utils directories that are used rather than hard-coded values

What's more, because we're moving the logic into the ad-hoc modules that actually care about this, it should mean we integrate better with upcoming nuxi-ng, but definitely cc: @pi0 in case you foresee any issues here.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codesandbox
Copy link

codesandbox bot commented Mar 8, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

Copy link
Member

@Atinux Atinux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much better now and also bringing back a needed feature from Nuxt 2 to Nuxt 3 (ie: Tailwind module for instance)

@danielroe danielroe merged commit 9036142 into main Mar 9, 2023
@danielroe danielroe deleted the feat/watch branch March 9, 2023 11:46
@danielroe danielroe mentioned this pull request Mar 10, 2023
@mcfarljw
Copy link

This feature hasn't been added to the documentation yet.

@KnifeFed
Copy link

How do you use this? I tried all imaginable combinations of watch: ['tailwind.config.ts'] but it's not restarting the server when changing the file.

Copy link
Member Author

@KnifeFed Those paths need to be absolute. I've merged a fix to allow you to use paths relative to your srcDir, which will be included in the next patch release.

@FreekVR
Copy link

FreekVR commented Jun 26, 2023

Is the fix for relative paths confirmed to be merged?

I've tried every variation, but the watcher only works with abspath for me on nuxt 3.6.0

    watch: [
        '/assets/styles/css-variables.js'
    ],
    watch: [
        './assets/styles/css-variables.js'
    ],
    watch: [
        'assets/styles/css-variables.js'
    ],
    watch: [
        '@/assets/styles/css-variables.js'
    ],

@danielroe
Copy link
Member Author

@FreekVR Yes, this was merged. If you are experiencing a regression, please do open a new issue with a reproduction.

@plcdnl
Copy link

plcdnl commented Jul 23, 2023

I'm so sorry but i'm trying to do it with nuxt 3.6.5 and it doesn't restart the app. Both with the absolute url and with the relative one

Copy link
Member Author

Let's track in #22272.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants