Getting started
This guide will help you get up and running with the Nasjonalbiblioteket monorepo, covering structure, installation, development workflows, and conventions.
Last modified: October 25, 2021
Requirements
- PHP 8.2 (managed via Composer)
- Node 20 (managed via npm)
- Composer - For PHP dependencies
- Local by Flywheel (recommended for local WordPress development)
Monorepo Structure
Packages (packages/)
WordPress code and shared frontend packages:
packages/wordpress/plugins/- Custom WordPress plugins (e.g.,nb-employee,nb-event,site-bibliotekutvikling)packages/wordpress/themes/- WordPress themes (e.g.,nb,bibliotekutvikling,kompetansebanken)packages/wordpress/mu-plugins/- Must-use plugins loaded automaticallypackages/wordpress/libraries/- Shared PHP librariespackages/wordpress/external-plugins/- Third-party premium plugins (ACF Pro, Gravity Forms, FacetWP, Polylang Pro, etc.)packages/styles/- Shared CSS packages (css-reset,forms,custom-media)packages/tools/- Build tools and webpack configuration
Sites (sites/)
Individual site deployments:
nb/- Main nb.no WordPress sitebibliotekutvikling/- bibliotekutvikling.no WordPress sitemaken/- Maken React app (Create React App) ⚠️ Currently inactive - build process broken since last design changengram/- N-gram viewer React + TypeScript appembed/- Reusable embeddable React componentstranslate/- Translation management sitetibi/- Tibi WordPress site
Documentation (docs/)
Developer documentation built with Eleventy:
getting-started.md- Setup and onboardinggit-workflow.md- Branch naming, rebase workflow, PR processpackages.md- Package documentationrelease-process.md- Deployment and release guide
View built docs: npm run docs:dev
Installation
For complete setup instructions, see INSTALLATION.md
Quick start:
git clone <repository-url>
composer install
npm install
npm run build
Development Workflows
Build & Watch
npm run dev # Turborepo parallel watch mode for all packages
npm run build # Production build all packages
Individual Sites
npm run dev:ngram # Start ngram dev server
cd sites/maken && npm start # Start maken dev server
Documentation
npm run docs:dev # Serve docs with live reload
npm run docs:build # Build static docs
Linting & Code Quality
npm run lint # Run all linters (JS, CSS, format check)
npm run lint-fix # Auto-fix linting issues
composer lint # PHP CodeSniffer
composer lint-fix # PHPCBF auto-fix
Package Management
The monorepo uses dual package managers:
npm Workspaces
JavaScript/TypeScript packages defined in root package.json:
packages/*
packages/styles/*
packages/tools/*
packages/wordpress/plugins/*
packages/wordpress/themes/*
Composer
PHP packages managed via Composer with symlink-based local packages.
Adding a New Package
WordPress plugin/theme/mu-plugin:
- Create folder in
packages/wordpress/{plugins|themes|mu-plugins}/your-package - Add
composer.jsonwith type (wordpress-plugin,wordpress-theme,wordpress-muplugin) - Add to root
composer.jsonunderrequire:"nb/your-package": "@dev" - Run
composer updatefrom project root - If it has front-end assets, add
package.jsonand update root package.json workspaces
Updating packages:
npm outdated- Identify packages to updatenpm update <package>- Update specific packagenpm update <package> -w <workspace>- Update in specific workspace
Build System
- WordPress packages: Built with
wp-scripts(WordPress webpack wrapper) - React apps: Create React App with custom configurations
- CSS: PostCSS pipeline with imports, nesting, custom media queries, autoprefixer
- Orchestration: Turborepo for parallel task execution
Deployment
All deployments are automated via GitHub Actions:
- WordPress sites: Deploy to GitLab repos via
.github/workflows/deploy-*-gitlab.yml - React apps: Build and deploy to GitLab (e.g.,
deploy-main-maken.yaml,deploy-main-ngram.yml) - Trigger:
mainbranch pushes deploy to staging/production
Conventions
Code Style
- PHP: Dekode Coding Standards (WordPress variant)
- JavaScript/TypeScript: WordPress ESLint rules with Prettier
- CSS: wp-scripts lint-style with PostCSS
- Pre-commit hooks via Husky enforce formatting
Translation
Norwegian locale (nb_NO) is primary:
- POT files in
languages/directory - Generate:
composer make-pot - Translation files:
.poand.moformat
Additional Resources
- Installation guide: INSTALLATION.md
- Git workflow: Git Workflow
- AI coding guide: .github/copilot-instructions.md