Skip to content

feat: restart dev server when tsconfig and tailwind config changes#4947

Merged
matthewp merged 14 commits into
mainfrom
feat/watch-targets
Oct 12, 2022
Merged

feat: restart dev server when tsconfig and tailwind config changes#4947
matthewp merged 14 commits into
mainfrom
feat/watch-targets

Conversation

@JuanM04
Copy link
Copy Markdown
Contributor

@JuanM04 JuanM04 commented Oct 1, 2022

Changes

Fixes #4913
Fixes #4914

There are some configuration files that require a full dev server restart to reflect their changes (like tsconfig.json and tailwind.config.js). I've added a method that let integrations add arbitrary files to a watch list: addWatchFile. When a change in a file declared in addWatchFile, the dev server performs a restart.

I've implemented this in the Tailwind integration and hardcoded tsconfigPath into the watch list.

Testing

N/A

Docs

withastro/docs#1655

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Oct 1, 2022

🦋 Changeset detected

Latest commit: f854d55

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@JuanM04 JuanM04 marked this pull request as ready for review October 1, 2022 12:28
@JuanM04 JuanM04 requested a review from a team as a code owner October 1, 2022 12:28
@github-actions github-actions Bot added pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) semver: minor Change triggers a `minor` release labels Oct 1, 2022
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

JuanM04 added a commit to withastro/docs that referenced this pull request Oct 1, 2022
@sarah11918 sarah11918 removed the request for review from a team October 2, 2022 21:58
Copy link
Copy Markdown
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

The implementation looks great! I have a couple nits around the API name, but I don't have the most context on the history of integrations, so happy to discuss some counterpoints too

Comment thread packages/astro/src/@types/astro.ts Outdated
Comment thread packages/astro/src/@types/astro.ts Outdated
Comment thread packages/astro/src/core/config/settings.ts Outdated
@matthewp matthewp merged commit a5e3ecc into main Oct 12, 2022
@matthewp matthewp deleted the feat/watch-targets branch October 12, 2022 15:36
@astrobot-houston astrobot-houston mentioned this pull request Oct 12, 2022
@JuanM04
Copy link
Copy Markdown
Contributor Author

JuanM04 commented Oct 12, 2022

Yei! @matthewp could you add the hacktoberfest-accepted label, please?

@matthewp
Copy link
Copy Markdown
Contributor

Yep, done!

sarah11918 added a commit to withastro/docs that referenced this pull request Oct 13, 2022
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
@mrcaidev
Copy link
Copy Markdown

Changes in tailwind.config.js still crashes dev server on my machine.

Using:

  • OS: WSL Arch
  • IDE: VSCode
  • Astro: v1.5.2
  • Package manager: Pnpm v7.14.0

Error message:

08:45:48 AM [astro] Unable to load /home/mrcai/mrcai.dev/astro.config.ts

 error   (0 , import_core.resolve) is not a function
  Code:
      53 |   }
    > 54 | }
         |                                                              ^
      55 | function tailwindIntegration(options) {
      56 |   var _a, _b;
      57 |   const applyBaseStyles = ((_a = options == null ? void 0 : options.config) == null ? void 0 : _a.applyBaseStyles) ?? true;
    
  Stacktrace:
TypeError: (0 , import_core.resolve) is not a function
    at getUserConfig (/home/mrcai/mrcai.dev/node_modules/.pnpm/@astrojs+tailwind@2.1.1_tailwindcss@3.2.1/node_modules/@astrojs/tailwind/dist/index.js:54:62)
    at astro:config:setup (/home/mrcai/mrcai.dev/node_modules/.pnpm/@astrojs+tailwind@2.1.1_tailwindcss@3.2.1/node_modules/@astrojs/tailwind/dist/index.js:91:34)
    at runHookConfigSetup (file:///home/mrcai/mrcai.dev/node_modules/.pnpm/astro@1.5.2/node_modules/astro/dist/integrations/index.js:70:60)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async dev (file:///home/mrcai/mrcai.dev/node_modules/.pnpm/astro@1.5.2/node_modules/astro/dist/core/dev/index.js:19:14)
    at async startDevServer (file:///home/mrcai/mrcai.dev/node_modules/.pnpm/astro@1.5.2/node_modules/astro/dist/cli/index.js:139:35)
    at async FSWatcher.<anonymous> (file:///home/mrcai/mrcai.dev/node_modules/.pnpm/astro@1.5.2/node_modules/astro/dist/cli/index.js:172:13)


file:///home/mrcai/mrcai.dev/node_modules/.pnpm/vite@3.1.8/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:57450
          cb(new Error('The server is not running'));
             ^

Error: The server is not running
    at WebSocketServer.<anonymous> (file:///home/mrcai/mrcai.dev/node_modules/.pnpm/vite@3.1.8/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:57450:14)
    at Object.onceWrapper (node:events:627:28)
    at WebSocketServer.emit (node:events:513:28)
    at WebSocketServer.emit (node:domain:489:12)
    at emitClose (file:///home/mrcai/mrcai.dev/node_modules/.pnpm/vite@3.1.8/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:57757:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)

Node.js v19.0.0
 ELIFECYCLE  Command failed with exit code 1.

@JuanM04
Copy link
Copy Markdown
Contributor Author

JuanM04 commented Oct 28, 2022

@mrcaidev that's odd. Make sure you have all your Astro deps up-to-date. Also, you could try renaming your tailwind config to tailwind.config.cjs and see if that does anything

@mrcaidev
Copy link
Copy Markdown

@mrcaidev that's odd. Make sure you have all your Astro deps up-to-date. Also, you could try renaming your tailwind config to tailwind.config.cjs and see if that does anything

All dependencies are up to date. cjs doesn't work. :(

@JuanM04
Copy link
Copy Markdown
Contributor Author

JuanM04 commented Oct 28, 2022

@mrcaidev Sorry, I can't reproduce the problem. If you can't fix it, open a new issue with a reproduction and mention me, so I get the notification

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

Labels

pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) semver: minor Change triggers a `minor` release

Projects

None yet

5 participants