doc/README.frontend.md
The ntopng frontend is compiled with Vite. All source lives in http_src/ and assets/;
the compiled output goes to httpdocs/dist/ and must be committed alongside code changes.
Node.js ≥ 18.15.0 is required.
Run once after cloning (or after package.json changes):
npm install
Rebuilds ntopng.js automatically on every file save under http_src/:
npm run watch
Watch mode rebuilds only the Vue app bundle (ntopng.js + ntopng.css). Run
npm run build once first to produce third-party.js, CSS themes, images, and
login.js — watch mode then preserves those files between rebuilds.
| Command | When to use |
|---|---|
npm run build | Full production build (JS + CSS + assets, minified) |
npm run build:dev | Full development build (unminified, with sourcemaps) |
npm run build:ntopngjs | Rebuild ntopng.js only (fast, preserves rest of dist) |
All commands output to httpdocs/dist/. Commit the dist output before opening a pull request.
npm run build / npm run build:dev runs build.mjs which executes five sequential
Vite passes, each producing a self-contained IIFE:
| Output file | Source |
|---|---|
third-party.js + third-party.css | assets/third-party.js (jQuery, Bootstrap, DataTables, …) |
ntopng.js + ntopng.css | http_src/ntopng.js (Vue app + SCSS) |
dark-mode.css / white-mode.css / custom-theme.css | Theme SCSS files |
images/flags.png, images/blank.gif, etc. | assets/images/images.js |
login.js | assets/scripts/login.js (particle animation) |
All bundles are plain IIFEs loaded as type="application/javascript" (classic blocking
scripts). third-party.js must load first — it sets window.$, window.moment, and
other globals that ntopng.js depends on.
npm run css:lint # SCSS linting (stylelint)
npm run js:lint # JS linting (eslint)