Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
generator-mc-d8-theme
Advanced tools
Yeoman generator for creating Drupal 8 component based themes.
The Theme Generator is a scafolding tool built by your friends at Mediacurrent, which lets you quickly set up a Drupal 8 or 9 theme with sensible defaults and best practices.
While the theme generator can be run anywhere, it's happiest when it's run from an empty directory you'd like to become your theme.
While not a requirement we like to use NVM to manage the version of Node per project.
Create a new directory. Example:
themes/custom/my_awesome_theme
Move into the new directory and install Node:
cd my_awesome_theme
nvm install 14.16.1 && node -v > .nvmrc
This will install version NodeJS v14.16.1
.
It will create .nvmrc
in the root of your project.
Theme Generator is compatible with npm v6.
npm install -g npm@6.14.12
From now on, when working on this theme change into its directory and run nvm use
and NVM will switch to the specified version for you.
Run the generator (Do not change this command):
npm create yo mc-d8-theme
IMPORTANT: Your theme's machine name should always match the directory name you created above.
More info if you're interested in how this stuff works:
npm create
is an alias of npm init
and uses npx under the hood. Find out more about npm init.
If you are building a Drupal 8 theme, make the following updates after your theme has been created:
Update Pattern Lab to v5.14.0 by updating package.json
as follows:
"@pattern-lab/core": "5.14.0",
"@pattern-lab/engine-twig-php": "5.14.0",
"@pattern-lab/uikit-workshop": "5.14.0",
Remove node_modules
Run npm install
This theme uses Twig namespaces. In order for these to work in Drupal you must install the Components Library module.
The following is supported by your new theme.
The theme generator allows you to (optionally) add example components.
🌧 = Preconfigured for the Rain Install Profile.
These can include both component and Drupal templates that are added to the appropriate place during theme generation. Your theme.libraries.yml is also updated to include the relevant libraries.
This can also be run within a pre-existing theme using:
npx yo mc-d8-theme:starter-kit
You can also generate base components with the right files in place using:
npm run generate
This is helpful if you are building out a new theme and would like to quickly create lots of new components with the libraries already wired up.
TLDR: Don't do it if you can avoid it.
Every time Pattern Lab is rebuilt the cache busting strings will change on CSS and JS files. dependencyGraph.json
will also be updated every single time which makes reviewing pull requests rather difficult.
Optimally we want to gitignore all /.dist
files and run npm run build
as part of a continuous integration process.
Change what browsers your theme supports by updating browserslist within package.json
. For options take a look at browserslist.
This impacts CSS browser prefixes and JavaScript compiled files.
screenshot.png
with your own theme image../src/patterns/global/fonts/
../src/patterns/global/colors/
.Provided by default are seven npm scripts that point to Gulp tasks. We run gulp through npm scripts.
Run the default build task (gulp in this instance) and everything in it.
This is the equivalent to running gulp
on the command line with Gulp installed globally.
npm run build
Compile Sass and JS.
npm run compile
Watch files and run tasks when they change.
npm run watch
Compress png and svg assets.
npm run compress
Build Pattern Lab.
npm run styleguide
Lint Sass and JS files.
npm run lint
Delete compiled Sass, JS and style guide files from the /dist directory.
npm run clean
Would you like to contribute? Want to make a few changes or fix a bug? COME ON OVER!
git clone git@github.com:mediacurrent/theme_generator_8.git
cd theme_generator_8
Remove generator-mc-d8-theme
if you have previously installed it:
Tip: use npm ls -g -depth=0
to see what global node modules are installed.
npm uninstall generator-mc-d8-theme -g
Use the node version of the generator
nvm install
nvm use
Install the generator's dependencies
npm install
Link your local generator files to npm:
npm link
Now whenever you run yo mc-d8-theme
it'll use your locally cloned mc-d8-theme generator. Any updates done to the generator can be tested in real time.
Break off a feature branch dive right in. After you've got something you'd like to add, push back to the repo and pull request against develop.
To test the changes you've made locally, ensure your new theme uses the same version of node as the generator.
FAQs
Yeoman generator for creating Drupal 8 component based themes.
The npm package generator-mc-d8-theme receives a total of 64 weekly downloads. As such, generator-mc-d8-theme popularity was classified as not popular.
We found that generator-mc-d8-theme demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.