Using Aliases

PIB comes with a number of built-in aliases to make importing easier.

Without aliases, if you want to import a file from your src/content directory in your src/components/index/page.js your import statement would look like this:

import headline from '../../content/headline.txt'

And those .. would only increase as your project became more complicated. However, because PIB already has aliases, you can instead import it from anywhere in your codebase like this:

import headline from 'Content/headline.txt'

The aliases included in PIB are:

  • DataYourProject/src/data

  • CommonYourProject/src/components/common

  • ContentYourProject/src/content

  • ThemeYourProject/src/theme

  • UtilsYourProject/src/utils

  • package.jsonYourProject/package.json

  • politico-componentsYourProject/node_modules/politico-style/js/lib/components/base

Last updated