[PR #7183] [CLOSED] feat: add yarn dev watcher script #13220

Closed
opened 2025-12-29 22:26:03 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/7183
Author: @ndom91
Created: 9/5/2021
Status: Closed

Base: developHead: ndom91/frontend-dev-script


📝 Commits (10+)

📊 Changes

4 files changed (+95 additions, -6 deletions)

View changed files

netbox/extras/management/commands/dev.py (+22 -0)
netbox/extras/management/commands/uidev.py (+37 -0)
📝 netbox/project-static/bundle.js (+35 -6)
📝 netbox/project-static/package.json (+1 -0)

📄 Description

Fixes:

Added a javascript script in the root of /netbox/project-static in order to make the frontend development workflow a bit nicer.

You can now run yarn dev and it'll begin watching ../project-static/src/**/*.ts and ../project-static/styles/**/*.scss for changes. When any of the above files is detected to have changed, it'll automatically run the appropriate transpile step (bundle.js) and also the manage.py collectstatic step.

Therefore, the developer just makes the changes to the sass / ts files, waits a second or so and reloads their development netbox tab to see the updated changes. This gets us a bit closer to the normal modern js development flow of hot reloading everything 🎉

This does require 1 new dependency, chokidar a node file watcher, but it's only a dev dependency and so is only installed during development and is not part of the bundle that gets sent to netbox users.

Example output:
image

CC: @thatmattlove


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/7183 **Author:** [@ndom91](https://github.com/ndom91) **Created:** 9/5/2021 **Status:** ❌ Closed **Base:** `develop` ← **Head:** `ndom91/frontend-dev-script` --- ### 📝 Commits (10+) - [`7ce0cde`](https://github.com/netbox-community/netbox/commit/7ce0cdedb07f03d94ed5e853288fb7957ebb9d47) feat: add yarn dev watcher script - [`968e96d`](https://github.com/netbox-community/netbox/commit/968e96d2fdce34e25d3297a4ca42c8fdd5ba1487) feat: cleanup dev script output - [`2bc8751`](https://github.com/netbox-community/netbox/commit/2bc87516d28c548a15b088dda0f084e6488fe9d9) chore: prettier - [`aecd2d2`](https://github.com/netbox-community/netbox/commit/aecd2d22aeef24a210b78a93261cafa64bf08122) fix: output - [`c3fa593`](https://github.com/netbox-community/netbox/commit/c3fa59312c77862fe8e9ad3cceb25288782dfb95) fix: error output - [`9a51849`](https://github.com/netbox-community/netbox/commit/9a51849012aa6a5037ad26d337a191886d6d002a) fix: simplify type flag logic - [`d160de0`](https://github.com/netbox-community/netbox/commit/d160de00d338c45cd22d4bc583e5c4d8053d87fc) fix: simplify dev reload - [`fbb9529`](https://github.com/netbox-community/netbox/commit/fbb9529f633fdf8de28a849850c0bde8737ff43d) fix: use esbuild to watch files in dev - [`c3b9576`](https://github.com/netbox-community/netbox/commit/c3b9576ec761b4c275dd6779c46948e5fedb0e82) chore: rm chokidar - [`c725696`](https://github.com/netbox-community/netbox/commit/c725696d41e11556f5d1e98cfae9af586d1d2c33) chore: cleanup ### 📊 Changes **4 files changed** (+95 additions, -6 deletions) <details> <summary>View changed files</summary> ➕ `netbox/extras/management/commands/dev.py` (+22 -0) ➕ `netbox/extras/management/commands/uidev.py` (+37 -0) 📝 `netbox/project-static/bundle.js` (+35 -6) 📝 `netbox/project-static/package.json` (+1 -0) </details> ### 📄 Description <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be opened for approval prior to filing a pull request. This helps avoid wasting time and effort on something that we might not be able to accept. Please indicate the relevant feature request or bug report below. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ACCEPTED BUG REPORT OR FEATURE REQUEST, IT WILL BE MARKED AS INVALID AND CLOSED. --> ### Fixes: <ISSUE NUMBER GOES HERE> <!-- Please include a summary of the proposed changes below. --> Added a javascript script in the root of `/netbox/project-static` in order to make the frontend development workflow a bit nicer. You can now run `yarn dev` and it'll begin watching `../project-static/src/**/*.ts` and `../project-static/styles/**/*.scss` for changes. When any of the above files is detected to have changed, it'll automatically run the appropriate transpile step (`bundle.js`) and also the `manage.py collectstatic` step. Therefore, the developer just makes the changes to the sass / ts files, waits a second or so and reloads their development netbox tab to see the updated changes. This gets us a bit closer to the normal modern js development flow of hot reloading everything :tada: This does require 1 new dependency, `chokidar` a node file watcher, but it's only a dev dependency and so is only installed during development and is not part of the bundle that gets sent to netbox users. Example output: ![image](https://user-images.githubusercontent.com/7415984/132109163-462b4288-cb41-411e-aa6c-089121f7236d.png) CC: @thatmattlove --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 22:26:03 +01:00
adam closed this issue 2025-12-29 22:26:03 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13220