In order to be able to use modern CSS features, we're using PostCSS for compiling creating CSS that is supported by some of the older browsers that are still supported.
Core Patch Contributor Workflow
At the time being, this only affects contributors making changes to the experimental Claro theme.
Pre-requisites
Before starting, ensure that you are using at least the latest LTS release of Node.js, which is available for your platform here. Follow the installer instructions to ensure Node.js is installed correctly. If you want to manage Node.js with a package manager, instructions are available here for many common package managers.
Once Node.js has been installed, we recommend Yarn (over NPM) for managing dependencies. Install Yarn either with the instructions here, or with NPM.
npm i -g yarn
Once finished installing Node.js and Yarn, navigate to the core/ directory and type yarn install to install all of the dependencies required to lint and build core JavaScript.
Working on core CSS
When developing core CSS locally you can use the watcher to make changes and have them compiled as you save.
cd core
yarn install
yarn run watch:css
This watcher will only watch changes in files with the .pcss.css extension.
Building core CSS
To build all CSS run yarn run build:css. This will create .css versions of the .pcss.css files.
If you want to only compile a specific file you can pass the --file flag.
yarn run build:css -- --file themes/seven/css/base/elements.pcss.css
Creating a core patch or merge request
Since drupal.org package management does not build CSS and we can't change our build process in a minor release, you will need to include the compiled files in any patches or merge requests submitted to drupal.org. Before creating a patch or a merge request, build core's CSS as above and then submit a patch or merge request which includes all the changes. The diff should include changes to .pcss.css and .css files.
Reviewing a core patch or merge request
Using PostCSS is optional. Drupal continues to accept patches that only change .css, as long as .pcss.css file is not present for the file being modified.
If [filename].pcss.css exists, it's important to check that a compiled [filename].css file is also present. It is also important to review the .pcss.css changes and then ensure that if you compile the .pcss.css files you end up with the same patch.
Comments
Why Yarn ?
What is the reason we are using Yarn here?
You can use npm as well.
You can use npm as well.
yarn complains with /usr/bin
yarn complains with
/usr/bin/env: 'node': No such file or directory. This should be explained as well.The engine "node" is incompatible with this module
While trying to run
yarn install, I get the errorHow can I fix this?
Node version is incompatible
You are using incompatible version of Node. You can use nvm for installing a version that is compatible: https://github.com/nvm-sh/nvm.
Shouldn't we use Yarn 2?
Yarn 2 is now the recommended version, it use Plug'n'Play instead of the heavy
/node_modulesfolder, and we can also get the benefits of the Zero-Installs feature, which will guarantee that everybody is working with the same dependencies. If we stick with Yarn v1, by the time this gets launched it will be outdated.Regarding the file extensions for postcss, shouldn't we be using
.pcssinstead of.pcss.css? I haven't been able to find any convention on it but this https://twitter.com/PostCSS/status/661645290622083073-------------------------------------------------
take a look -> www.altrugon.com