Skip to content

Commit

Permalink
Merge pull request #2 from odestry/vite-plugin
Browse files Browse the repository at this point in the history
feat: added vite plugin
  • Loading branch information
blanklob authored Aug 17, 2024
2 parents e41fe9f + 714420e commit bc59786
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 23 deletions.
25 changes: 20 additions & 5 deletions .shopifyignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@

.DS_Store
.DS_Store?
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
node_modules
package.json
package-lock.json
pnpm-lock.yaml
bun.lockb

postcss.config.cjs
tailwind.config.cjs
vite.config.js
.editorconfig
.eslintrc.cjs
.prettierrc.cjs
jsconfig.json

.gitignore
.shopifyignore
.prettierignore
.eslintignore
.theme-check.yml
*.md
/.vscode
/.vim
assets/.vite/
11 changes: 11 additions & 0 deletions assets/.vite/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"entry.theme.js": {
"file": "entry.theme.-1DTOjwF.min.js",
"name": "entry.theme",
"src": "entry.theme.js",
"isEntry": true,
"css": [
"entry.YiHgjETv.min.css"
]
}
}

Large diffs are not rendered by default.

File renamed without changes.
3 changes: 3 additions & 0 deletions components/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function counter (num) {
return num + 1
}
1 change: 1 addition & 0 deletions components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { counter } from './counter'
5 changes: 5 additions & 0 deletions entry.theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import '~/styles/tailwind.css';

import { counter } from '~/components'

console.log(counter(1))
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"name": "theme-name",
"name": "theme-starter",
"version": "1.0.2",
"private": true,
"type": "module",
"private": true,
"scripts": {
"dev": "run-p -sr shopify:dev watch",
"shopify:dev": "shopify theme dev -e dev",
"dev": "run-p -sr \"shopify:dev -- {@}\" \"vite:dev\" --",
"shopify:dev": "shopify theme dev",
"vite:dev": "vite",
"pull": "shopify theme pull -d -o sections/*.json templates/*.json templates/customers/*.json config/settings_data.json",
"watch": "vite build -w",
"build": "vite build --minify",
"build": "vite build",
"release": "bumpp"
},
"devDependencies": {
"@by-association-only/vite-plugin-shopify-clean": "^2.0.0",
"@shopify/cli": "^3.65.3",
"@shopify/prettier-plugin-liquid": "^1.5.0",
"@shopify/theme": "^3.58.2",
Expand All @@ -21,6 +22,7 @@
"postcss": "^8.4.41",
"prettier": "^3.3.3",
"tailwindcss": "^3.4.10",
"vite": "^5.4.1"
"vite": "^5.4.1",
"vite-plugin-shopify": "^3.0.1"
}
}
4 changes: 2 additions & 2 deletions snippets/entry.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
{% endcomment %}
{% assign path = entry | replace: '~/', '../../' | replace: '@/', '../' %}
{% if path == "/entry.theme.js" or path == "../../entry.theme.js" %}
<script src="{{ 'entry.theme.DAmrlBVT.min.js' | asset_url | split: '?' | first }}" type="module" crossorigin="anonymous"></script>
{{ 'entry.DJqbQjLU.min.css' | asset_url | split: '?' | first | stylesheet_tag: preload: preload_stylesheet }}
<script src="{{ 'entry.theme.-1DTOjwF.min.js' | asset_url | split: '?' | first }}" type="module" crossorigin="anonymous"></script>
{{ 'entry.YiHgjETv.min.css' | asset_url | split: '?' | first | stylesheet_tag: preload: preload_stylesheet }}
{% endif %}
File renamed without changes.
28 changes: 20 additions & 8 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
import { defineConfig } from 'vite'
import { defineConfig } from 'vite';
import path from 'path'
import shopify from 'vite-plugin-shopify';
import cleanup from '@by-association-only/vite-plugin-shopify-clean'

export default defineConfig({
resolve: {
alias: {
'~': path.resolve(__dirname, './'),
},
},
plugins: [
shopify({
additionalEntrypoints: ['entry.theme.js'],
snippetFile: 'entry.liquid'
}),
cleanup()
],
build: {
outDir: 'assets',
emptyOutDir: false,
minify: false,
rollupOptions: {
input: 'styles.css',
output: {
dir: 'assets',
assetFileNames: '[name][extname]',
entryFileNames: '[name].[hash].min.js',
chunkFileNames: '[name].[hash].min.js',
assetFileNames: '[name].[hash].min[extname]'
}
}
}
})
});

0 comments on commit bc59786

Please sign in to comment.