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:
    Data β†’ YourProject/src/data
    Common β†’ YourProject/src/components/common
    Content β†’ YourProject/src/content
    Theme β†’ YourProject/src/theme
    Utils β†’ YourProject/src/utils
    package.json β†’ YourProject/package.json
    politico-components β†’ YourProject/node_modules/politico-style/js/lib/components/base
Last modified 2yr ago
Copy link