The v12 release marks a major transition from small, single-purpose npm packages (primer-core, primer-marketing, primer-utilities, etc.) to a single package — @primer/css — which contains all of the SCSS source files in subdirectories. Here's what you need to do to migrate different parts of your app:
First, install the new package.
npm install --save @primer/cssIf you use the primer package, all you'll need to do is:
npm uninstall --save primerIf you use other packages, such as primer-utilities, you will need to uninstall each one by name or use a command line tool like jq to list them:
jq -r '.dependencies | keys[] | select(.|startswith("primer"))' package.jsonAnd, if you're feeling saucy, uninstall them all by piping that to xargs npm uninstall. ✨
There are a couple of things you'll need to change in your Sass setup when migrating to v12. This section is intentionally vague because environments vary wildly between text editors, Sass implementations, and application frameworks. When in doubt, consult the relevant documentation, and feel free to file an issue if you think that we can help.
Generally speaking, all of your Sass @import statements can be migrated with the following search-and-replace operations, in the following order:
- If you import
primer/index.scssorprimer, just replaceprimerwith@primer/cssand you're done! - Otherwise...
- Replace
primer-marketing-with@primer/css/marketing/, e.g.primer-marketing-buttons/index.scssbecomes@primer/css/marketing/buttons/index.scssprimer-marketing-utilities/index.scssbecomes@primer/css/marketing/utilities/index.scss
- Replace
primer-with@primer/css/, e.g.primer-markdown/index.scssbecomes@primer/css/markdown/index.scssprimer-utilities/index.scssbecomes@primer/css/utilities/index.scss
- Delete
lib/from every Primer CSS path, e.g.primer-forms/lib/form-control.scssbecomes@primer/css/forms/form-control.scssprimer-navigation/lib/subnav.scssbecomes@primer/css/navigation/subnav.scss
- Replace
If your text editor supports search and replace regular expressions, the following patterns should work:
| find | replace |
|---|---|
primer-marketing-(\w+)(\/lib)? |
@primer/css/marketing/$1 |
primer-(\w+)(\/lib)? |
@primer/css/$1 |
primer\b |
@primer/css |
You can also use the included primer-migrate script:
npx -p @primer/css primer-migrate path/to/**/*.scssIf you've installed Primer CSS with npm, you very likely already have node_modules listed in your Sass includePaths option, and you won't need to change anything. 🎉
If you've installed Primer CSS with something other than npm, or you don't know how it was installed, consult the documentation for your setup first, then let us know if you still can't figure it out.
The compiled CSS files can be found under /dist in case you want to directly link to them.
The marketing-specific font files published in the fonts directory of primer-marketing-support@2.0.0 are published in the fonts directory of @primer/css. If you use these fonts, you'll need to do the following:
- Update any scripts that copy the
.wofffont files fromnode_modules/primer-marketing-support/fontsinto your application to look for them innode_modules/@primer/css/fonts. - Update any webpack (or other bundler) resolution rules that look for fonts in
primer-marketing-support/fontsto look for them in@primer/css/fonts. - Customize the
$marketing-font-pathvariable to match the path from which they're served.