The UTKSDS Plugin uses Node to compile and compress Javascript and CSS from source files.
git clone
this project by typing git clone git@github.com:utkwdn/utksds-plugin.git
./utksds-plugin/
directory.npm install
to install dependencies.This project was designed to be as simple as possible. To that end, all that you need to do to create a new block is to navigate to the /wp-data/-wp-content/plugins/utds/src
subdirectory, create a new folder and source files for your desired block, and import it in the blocks.js
file. For example: import './newblock/newblock.js';
Additionally, you could simply copy another block's folder, rename the folder and files, and then change the name of the block within the registerBlockType
function within the copied directory's .js file. Please be sure to assign the block a unique name, and ensure that it is being assigned to the correct category, or unexpected results may occur.
Inside the blocks.js
file in the src
directory, there is a section, indicated by a comment, that will allow developers to selectively toggle available blocks by passing the respective wordpress block slug to the blocktodisable
array. The function is as simple as adding/removing the respective slug from the array.
Within each block are .scss
files, one of which is called editor.scss
. These files can really be called anything, but I recommend maintaining the convention of calling editor specific scss files as such. These files are imported in the block's respective .js file. SASS/SCSS can be used as usual within these files, and they will be automatically processed into css by npm/yarn when the npm start
or yarn start
command is run.
Occasionally, there have been problems with incompatible dependencies. For this reason, I recommend using yarn/yarnpkg instead of npm, to ensure that the same version of repective dependencies is maintained across all instances of the plugin.
There have also been problems with permissions in some cases, typically with media files and uploads of static assets, such as photos. This will probably not be an issue for MAC or Windows users, but directory permissions/ownership may need to be modified for docker users.
Below you will find some information on how to run scripts.
You can find the most recent version of this guide here.
npm start
npm run build
dist
folder.npm run eject
create-guten-block
.eject
and you have to maintain everything yourself.eject
a project because by ejecting you lose the connection with create-guten-block
and from there onwards you have to update and maintain all the dependencies on your own.