From 79c54ce99868ec36bce560176caea02849b741d3 Mon Sep 17 00:00:00 2001 From: Adrian D'Alessandro Date: Tue, 20 Oct 2026 16:22:18 +0100 Subject: [PATCH 1/6] Move frontend configuration into node/ folder. Assisted by: GPT-6.1 Sol --- .github/workflows/node-ci.yml | 10 ++- .gitignore | 1 + .pre-commit-config.yaml | 2 +- README.md | 9 ++- docs/dev-guide/templates.md | 5 +- .eslintrc.js => node/.eslintrc.js | 0 .prettierignore => node/.prettierignore | 2 +- .prettierrc => node/.prettierrc | 0 {.storybook => node/.storybook}/main.js | 4 +- {.storybook => node/.storybook}/preview.js | 0 .stylelintrc.json => node/.stylelintrc.json | 2 +- node/README.md | 42 ++++++++-- node/build/build.test.js | 85 +++++++++++++++++++++ node/build/config.js | 10 ++- node/build/scripts.js | 2 +- node/build/styles.js | 18 +++-- node/build/vendor.js | 2 +- package-lock.json => node/package-lock.json | 0 package.json => node/package.json | 14 ++-- vitest.config.js => node/vitest.config.js | 0 20 files changed, 173 insertions(+), 35 deletions(-) rename .eslintrc.js => node/.eslintrc.js (100%) rename .prettierignore => node/.prettierignore (71%) rename .prettierrc => node/.prettierrc (100%) rename {.storybook => node/.storybook}/main.js (76%) rename {.storybook => node/.storybook}/preview.js (100%) rename .stylelintrc.json => node/.stylelintrc.json (83%) create mode 100644 node/build/build.test.js rename package-lock.json => node/package-lock.json (100%) rename package.json => node/package.json (83%) rename vitest.config.js => node/vitest.config.js (100%) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 5dcc6f9d..1ae1ef10 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -14,6 +14,9 @@ jobs: run-tests: name: Run tests runs-on: ubuntu-latest + defaults: + run: + working-directory: node steps: - uses: actions/setup-node@v7 with: @@ -21,12 +24,15 @@ jobs: - name: Check out Git repository uses: actions/checkout@v7 - name: Install dependencies - run: npm install + run: npm ci - name: Run tests run: npm run test-ci run-lint: name: Run lint runs-on: ubuntu-latest + defaults: + run: + working-directory: node steps: - uses: actions/setup-node@v7 with: @@ -34,6 +40,6 @@ jobs: - name: Check out Git repository uses: actions/checkout@v7 - name: Install dependencies - run: npm install + run: npm ci - name: Run lint run: npm run lint diff --git a/.gitignore b/.gitignore index 3892c2b8..185b8c6b 100644 --- a/.gitignore +++ b/.gitignore @@ -156,3 +156,4 @@ bower_components/ main/static/assets/img2 *storybook.log +node/storybook-static/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a9e4abbc..6c494531 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,7 +55,7 @@ repos: hooks: - id: codespell args: [-I, .codespell_ignore.txt] - exclude: ^main/static/assets/|^package-lock.json$|^direct_webapp/fixtures/framework-2-0.json$ + exclude: ^main/static/assets/|^node/package-lock.json$|^direct_webapp/fixtures/framework-2-0.json$ - repo: https://github.com/djlint/djLint rev: v1.47.1 hooks: diff --git a/README.md b/README.md index fbbdab15..815a5d68 100644 --- a/README.md +++ b/README.md @@ -159,7 +159,14 @@ Versions can be restricted from updating within the `pyproject.toml` using stand ## Frontend Node -This project includes an NPM-based setup for managing front-end assets like styles, scripts, and other resources. The `package.json` file contains predefined scripts to help with building and managing assets. You don't need to run these NPM commands if you are developing the Django app locally. You should only run these commands when needed, for example if you are changing javascript dependencies or modifying SCSS files. +The front-end build is contained in [node/](node/README.md), including its package +manifest, lockfile, tooling configuration, sources and tests. You do not need +Node.js to develop Django pages using the committed assets. Only rebuild when +changing front-end sources or dependencies. + +Run npm commands from `node/`, or use `npm --prefix node` from the repository root. +Built assets remain in `main/static/assets/`; Django deployment still consumes +those assets without running npm. See [Frontend Node](node/README.md) for details on working with the NPM-based frontend asset pipeline. diff --git a/docs/dev-guide/templates.md b/docs/dev-guide/templates.md index 6eb6b026..d8769b4d 100644 --- a/docs/dev-guide/templates.md +++ b/docs/dev-guide/templates.md @@ -71,7 +71,7 @@ Run the configured `djlint-django` and `djlint-reformat-django` pre-commit hooks for changed templates. Use `pyproject.toml` as the authority for djlint rules and existing exceptions; do not add a separate formatting convention. -For unavoidable SCSS changes, use the existing stylesheet scripts: +For unavoidable SCSS changes, use the existing stylesheet scripts from `node/`: ```bash npm run styles:expanded @@ -79,7 +79,8 @@ npm run styles:minified ``` These scripts lint SCSS with Stylelint before compiling the theme. Stylelint -rules live in `.stylelintrc.json`. The broader `npm run build` also builds +rules live in `node/.stylelintrc.json`. From the repository root, use +`npm --prefix node run