Welcome to the cdnjs/static-website repository, the home of the new cdnjs website built with Vue & Nuxt, following the new cdnjs branding proposal from cdnjs/brand.
This website relies completely on the cdnjs API to operate, resulting in very low resource usage to serve the site and limited app logic to update data being used (only sitemaps have to be updated, everything else uses API calls when a page is loaded).
This project runs on Node.js. Please make sure you have a version installed that matches our defined requirement in the .nvmrc file for this project.
Included with this project is a dependency lock file. This is used to ensure that all installations of the project are using the same version of dependencies for consistency.
You can install the Node dependencies following this lock file by running:
npm ciOnce the dependencies are installed, the website is ready to run in development mode. To start Nuxt in development mode (without a custom server), run:
npm run devThe website is build using Nuxt and relies on Webpack to generate the client-side bundle used to render the site and provide interactivity. Due to this, we can use Webpack's analyzer to better understand what is contributing to the size of the final bundle.
To run the analyzer, use the following package script:
npm run dev:analyzeTo deploy this website to production, the following steps should be taken:
- Install dependencies with
npm ci - Build the site for production with
npm run build - Start the custom Express server with
npm run start
During the build step, we enable Sentry error logging and publish the sourcemaps for the site
directly to Sentry. This is done as in production we use minified, bundled JavaScript, so the
sourcemaps allow Sentry to show where an error originated from in the source code. To do this, the
info in .sentryclirc must be correct, and a valid Sentry auth token must be
provided in the SENTRY_AUTH_TOKEN env var.
For deployments to Heroku, the installation of dependencies and building the app will automatically
be done, with npm run start being defined in the Procfile.
To change the port that the app binds to, set the PORT environment var when running the script.
For our Heroku deployment, this is set automatically by Heroku.
The custom Express server is used to handle our sitemaps, as we have too many routes for Nuxt's
sitemap offering to handle reliably. During the build step (npm run build) initial sitemaps will
be generated. The Express server will then regenerate these every 30 minutes using the cdnjs API. A
log containing the outcome of the last generation in Express is available at /sitemap-log.txt on
the website.
Our full set of tests for linting can be run at any time with:
npm testIncluded in this repository are an eslint config file as well as a sass-lint config file to help with ensuring a consistent style in the codebase for the JS/Vue and SCSS used in the app.
To help enforce this, we use both eslint and sass-lint in our testing. To run eslint at any time, which checks the code style of any JavaScript and Vue files, you can use:
npm run test:eslinteslint also provides automatic fixing capabilities, these can be run against the codebase with:
npm run test:eslint:fixSimilarly, sass-lint can be run at any time to check the quality of all the SCSS files used in the app, by running:
npm run test:scssA secondary package, sass-lint-auto-fix, is available to help with automatically fixing some of the errors raised by sass-lint, which can be run with:
npm run test:scss:fixLike with npm test, which runs both eslint & sass-lint, a shorter package script is available to
automatically attempt to fix issues from both linting packages, which can be used by running:
npm run test:fix