A custom Drupal 9 base theme developed from scratch based on the Drupal core stable theme, and adopting modern front-end development best practices including:
- Npm manages front-end packages & dependencies.
- Grunt watches for front-end code changes and runs build tasks.
- Sass (with
scss
syntax) for pre-css processing. - Sass partial structure roughly follows the 7-1 Pattern.
- Autoprefixer for post-css processing adds vendor prefixes for cross-browser compatibility.
- SCSS and JS linting ensures code quality.
- SVG minification with grunt-svgmin.
- Theme breakpoints defined in
*.breakpoints.yml
are exposed to sass via Drupal-SASS-Breakpoints.
-
Ensure NPM, Ruby and Ruby Gems are installed on your system.
-
Run
npm install
. -
Run
gem install scss_lint
. -
Run
npm install -g grunt-cli
to usegrunt
on the command line.
-
During development, leave Grunt running in a terminal window to monitor for code changes and run tasks accordingly.
$ grunt
-
Be careful with scss-lint errors in the console which can prevent your SASS code from being compiled to CSS. Ideally, configure your code editor to warn or automatically de-lint SCSS files for you to increase flow.
-
Save SVG files in the
images/
folder and minify them using:$ grunt svgmin
There is no need to write PNG fallbacks unless required by the supported browsers list for this project.
$ npm update caniuse-db