Monumental's Shopify Starter Theme
Collection of files and packages meant to be dropped into any new or existing projects to add TailwindCSS and JavaScript bundling support.
Includes
- Parcel 2
- Babel
- TailwindCSS
- Tailwinds JIT compiler via CDN - since Shopify's live reload isn't that fast, this allows you to include tailwind JIT in the browser, which is nice for prototyping in the dev tools and adding tailwind classes.
- Prettier
- ESLint
- TypeScript - optional usage since Parcel 2 just transpiles to JS instead of type checking. This way VSCode can show errors and warnings in
.ts
files, but this setup doesn't actually use the typescript compiler(tsc
). - postcss-preset-env
Commands
- Start development:
npm start
- uses parcel to watch and output js files and
.css
or.scss
imports - uses tailwindcss cli to watch and output tailwind file using JIT compiler
- uses parcel to watch and output js files and
- Build for production:
npm run build
- cleans
.parcel-cache
directory and files generated during development inassets
folder so everything is fresh on each build - uses parcel to output minifed
js
andcss
files and uses babel onjs
files ifbrowserslist
is configured inpackage.json
- uses tailwindcss cli to check purge on
liquid
andjs
files and outputs optimized tailwind css
- cleans
Note: development and production files are output to theme's assets
folder
Getting started
- Copy
mon.liquid
into snippets - located inapp/liquid-helpers
- Render
mon.liquid
in theme'stheme.liquid
-{% render 'mon' %}
- Run
npm start
to watch changes to files inapp/scripts
and run tailwindcss JIT compiler - All
js
orts
files should have.mon.
between the file name and file prefix. Exampletheme.mon.js
. This allows.gitignore
to ignore built files andnpm clean
to remove the correct files from theassets
directory - Add
js
orcss
files to themon.liquid
file however you need to. For example, you might want a script or stylesheet to just load on one or select pages for peformance. - All files in
scripts
will by considered and entry files and create a new file in theassets
directory. If that's not what you intended, put the file inscripts/components
and then import it to a specific entry file. Or you can also create your own folder structures. For example,scripts/helpers
- When ready to build files for production or staging use
npm run build
Shopify CLI Commands
Since Shopify is ending support for ThemeKit, I intentionally did not include any shortcut scripts in the package.json
. Instead we should upload and download theme files as needed with the Shopify CLI Theme commands.