Skip to content

Commit

Permalink
Update preset
Browse files Browse the repository at this point in the history
  • Loading branch information
montalvomiguelo committed Feb 7, 2025
1 parent b8d8e7e commit 71b4830
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 61 deletions.
7 changes: 7 additions & 0 deletions docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ The recommended and most straightforward approach to get started with Shopify Vi
npx @preset/cli apply barrel/shopify-vite --path preset
```

The preset automatically sets up Vite and Tailwind CSS in your theme. You may add any of the following flags to customize the preset:

| Flag | Description |
| ------------------- | ---------------------------------------------------------------------- |
| `--no-base` | Skip installing Vite |
| `--no-tailwindcss` | Skip installing Tailwind CSS |

More information about the preset can be found on its [repository](https://github.com/barrel/shopify-vite/tree/main/preset).

::: info
Expand Down
2 changes: 1 addition & 1 deletion preset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lint": "eslint ."
},
"devDependencies": {
"@preset/core": "^0.11.0",
"@preset/core": "^0.11.3",
"@types/node": "^18.15.3",
"tsconfig": "workspace:*"
}
Expand Down
34 changes: 18 additions & 16 deletions preset/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,39 +90,41 @@ async function installTailwind (): Promise<void> {
await installPackages({
title: 'install Tailwind CSS',
for: 'node',
install: ['tailwindcss', 'autoprefixer', 'postcss'],
install: ['tailwindcss', '@tailwindcss/vite'],
dev: true
})

await group({
title: 'extract Tailwind scaffolding',
handler: async () => {
await extractTemplates({
title: 'extract Tailwind CSS config',
from: 'tailwind'
})

await editFiles({
title: 'remove placeholder CSS',
title: 'add Tailwind CSS imports',
files: 'frontend/entrypoints/main.css',
operations: [
{ type: 'remove-line', match: /charset/ }
{
skipIf: (content) => content.includes('tailwind'),
type: 'update-content',
update: (content) => content.replace('@charset "utf-8";', '@import "tailwindcss" source("../..");')
}
]
})

await editFiles({
title: 'add Tailwind CSS imports',
files: 'frontend/entrypoints/main.css',
title: 'register Tailwind CSS plugin',
files: 'vite.config.js',
operations: [
{
skipIf: (content) => content.includes('tailwind'),
skipIf: (content) => content.includes('import tailwindcss from \'@tailwindcss/vite\''),
type: 'add-line',
match: /import shopify from 'vite-plugin-shopify'/,
position: 'after',
lines: [
'@tailwind base;',
'@tailwind components;',
'@tailwind utilities;'
],
position: 'prepend'
'import tailwindcss from \'@tailwindcss/vite\''
]
},
{
type: 'update-content',
update: (content) => content.replace('shopify()', 'shopify(),\n tailwindcss()')
}
]
})
Expand Down
18 changes: 1 addition & 17 deletions preset/templates/default/.shopifyignore
Original file line number Diff line number Diff line change
@@ -1,17 +1 @@
package.json
jsconfig.json
package-lock.json
frontend/
vite.config.js
tailwind.config.cjs
postcss.config.cjs
.gitignore
.prettierignore
.prettierrc.json
.theme-check.yml
.vscode/
*.md
translation.yml
node_modules
.git/
.github/
assets/.vite/*
9 changes: 0 additions & 9 deletions preset/templates/default/jsconfig.json

This file was deleted.

6 changes: 0 additions & 6 deletions preset/templates/tailwind/postcss.config.cjs

This file was deleted.

12 changes: 0 additions & 12 deletions preset/templates/tailwind/tailwind.config.cjs

This file was deleted.

0 comments on commit 71b4830

Please sign in to comment.