This is a Craft CMS 3.x and Craft Commerce 3.x boilerplate Myth Digital use internally for projects. Originally inspired by Made By Shape Craft 3 boilerplate.
composer create-project myth-digital/craft-3-stack
./craft setup
, instead copy and edit the .env.example
file..env
is completed, run ./craft install
./craft setup/security-key
Follow the steps below to set up Commerce with your stack.
rm -rf config/project && mv config/project-stack-commerce config/project
./craft project-config/apply
cp src/images/* public/dist/images/
[] To Do - Add better solution for fallback images
Settings / Globals
Some settings are required post-install in order to finalise setup.
Globals > Site
(Required for Commerce)Globals > Commerce
. This should match the path of your templates directory. Ensure you use a forward slash before and after. For example: /shop/
. If you wish to have the shop at root level, just enter a forward slash /
.The stack ships default with Commerce.
rm -rf config/project && mv config/project-stack config/project
./craft project-config/apply
[] To Do - Build script
npm run dev
Your go to for local development
npm run prod
Generates production assets (Minify, favicon etc). Perfect for running on server.
npm run setup
If project already exists, this will pull, migrate and apply project config and run dev tasks
.env
filegeneral.php
config/project.yaml
)Components are small bits of a template, e.g. a button, input field that then either make up a block or a full template. Use the components
folder and name each component file by it's use case e.g. inputField.twig
.
Make sure to describe each component at the top of each component file so other developers know how it is used. If the component accepts any attributes, make sure you include a description of these at the top of each component (Camel Case) file (See the components/_example.twig
) file.
Blocks are large chunks of markup, or made up of smaller components. E.g. a block could be a form, with button and input field components included. Use the blocks
folder and name each component file (Camel Case) by it's use case e.g. largeForm.twig
(If a SASS file exists for a block, use the same file name).
Blocks ideally should be selectable via a Matrix Field so CP users can pick and choose these per template. In some cases this might not be possible though, e.g. if the page is dynamically generated.
[] Add Google Workbox [] rel="preload" fonts via a Webpack task [] Move some Twig components in to VueJS