Skip to content

Commit d6b6a99

Browse files
Update preset (#171)
1 parent b8d8e7e commit d6b6a99

File tree

7 files changed

+27
-61
lines changed

7 files changed

+27
-61
lines changed

docs/guide/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ The recommended and most straightforward approach to get started with Shopify Vi
1515
npx @preset/cli apply barrel/shopify-vite --path preset
1616
```
1717

18+
The preset automatically sets up Vite and Tailwind CSS in your theme. You may add any of the following flags to customize the preset:
19+
20+
| Flag | Description |
21+
| ------------------- | ---------------------------------------------------------------------- |
22+
| `--no-base` | Skip installing Vite |
23+
| `--no-tailwindcss` | Skip installing Tailwind CSS |
24+
1825
More information about the preset can be found on its [repository](https://github.com/barrel/shopify-vite/tree/main/preset).
1926

2027
::: info

preset/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"lint": "eslint ."
99
},
1010
"devDependencies": {
11-
"@preset/core": "^0.11.0",
11+
"@preset/core": "^0.11.3",
1212
"@types/node": "^18.15.3",
1313
"tsconfig": "workspace:*"
1414
}

preset/preset.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,39 +90,41 @@ async function installTailwind (): Promise<void> {
9090
await installPackages({
9191
title: 'install Tailwind CSS',
9292
for: 'node',
93-
install: ['tailwindcss', 'autoprefixer', 'postcss'],
93+
install: ['tailwindcss', '@tailwindcss/vite'],
9494
dev: true
9595
})
9696

9797
await group({
9898
title: 'extract Tailwind scaffolding',
9999
handler: async () => {
100-
await extractTemplates({
101-
title: 'extract Tailwind CSS config',
102-
from: 'tailwind'
103-
})
104-
105100
await editFiles({
106-
title: 'remove placeholder CSS',
101+
title: 'add Tailwind CSS imports',
107102
files: 'frontend/entrypoints/main.css',
108103
operations: [
109-
{ type: 'remove-line', match: /charset/ }
104+
{
105+
skipIf: (content) => content.includes('tailwind'),
106+
type: 'update-content',
107+
update: (content) => content.replace('@charset "utf-8";', '@import "tailwindcss" source("../..");')
108+
}
110109
]
111110
})
112111

113112
await editFiles({
114-
title: 'add Tailwind CSS imports',
115-
files: 'frontend/entrypoints/main.css',
113+
title: 'register Tailwind CSS plugin',
114+
files: 'vite.config.js',
116115
operations: [
117116
{
118-
skipIf: (content) => content.includes('tailwind'),
117+
skipIf: (content) => content.includes('import tailwindcss from \'@tailwindcss/vite\''),
119118
type: 'add-line',
119+
match: /import shopify from 'vite-plugin-shopify'/,
120+
position: 'after',
120121
lines: [
121-
'@tailwind base;',
122-
'@tailwind components;',
123-
'@tailwind utilities;'
124-
],
125-
position: 'prepend'
122+
'import tailwindcss from \'@tailwindcss/vite\''
123+
]
124+
},
125+
{
126+
type: 'update-content',
127+
update: (content) => content.replace('shopify()', 'shopify(),\n tailwindcss()')
126128
}
127129
]
128130
})
Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1 @@
1-
package.json
2-
jsconfig.json
3-
package-lock.json
4-
frontend/
5-
vite.config.js
6-
tailwind.config.cjs
7-
postcss.config.cjs
8-
.gitignore
9-
.prettierignore
10-
.prettierrc.json
11-
.theme-check.yml
12-
.vscode/
13-
*.md
14-
translation.yml
15-
node_modules
16-
.git/
17-
.github/
1+
assets/.vite/*

preset/templates/default/jsconfig.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

preset/templates/tailwind/postcss.config.cjs

Lines changed: 0 additions & 6 deletions
This file was deleted.

preset/templates/tailwind/tailwind.config.cjs

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)