Skip to content

Commit 53c7ffa

Browse files
authored
Merge pull request #4 from sergejcodes/dev
Dev
2 parents 4c3e3c2 + c118517 commit 53c7ffa

File tree

14 files changed

+128
-28
lines changed

14 files changed

+128
-28
lines changed

.config/.readme/auto-reload-demo.gif

904 KB
Loading

.config/reloadr/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Reloadr
2+
3+
Reloadr is a custom script for reloading a remote Shopify theme during development.
4+
5+
The `reloadr.server.js` script runs a http server, as well as a websocket server, locally. The http server listens for requests, send from the `shopify:watch` task (which is the default Shopify Them Kit [watch task](https://shopify.github.io/themekit/commands#watch)) and communicates via websocket connection with the `reloadr.client.js` script.
6+
7+
The `reloadr.client.js` script (websocket client) is injected into the webpack bundle, during development, and connects via `localhost:port` to the websocket server. The script listens to reload messages from the server script.
8+
9+
Settings and ports for the script can be adjusted in the `packages.json`.
10+
11+
## Settings
12+
| Option | Description |
13+
| - | - |
14+
| serverPort | the localhost port `shopify:watch` task and `reloadr.server.js` use to communicate |
15+
| websoketPort | the localhost port `reloadr.server.js` and `reloader.client.js` use to communicate |
16+
| delay | auto reload needs a slight delay before reloading the remote site, so all newly uploaded files will be loaded. Values between `1500`ms and `2000`ms seem to work well |

.config/shopify/shopify.init.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
/**
2+
* this is a script to quickly initialize the local development environment and a remote shopify theme
3+
*/
14
const path = require('path')
25
const fs = require('fs-extra')
36
const commandLineArgs = require('command-line-args')
47
const yaml = require('yaml')
58
const axios = require('axios')
69
const chalk = require('chalk')
7-
const themeKit = require('@shopify/themekit')
10+
const themeKit = require('@shopify/themekit') // node wrapper for https://shopify.github.io/themekit
811

912
/**
1013
* get command line arguments

.config/shopify/shopify.sample.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# this is a sample file for illustration purposes and can be safely deleted
2+
# run shopify:init to initialize a new shopify config
13
dev:
24
password: [your-api-password]
35
theme_id: "[your-theme-id]"

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ The kit provides an easy way to build a custom Shopify theme from scratch. It co
1010
- Shopify Theme Kit
1111
- Vue
1212
- Vuex
13+
- Axios
1314
- SCSS
1415
- Tailwind CSS
1516
- Webpack
1617
- ESLint
1718
- Auto-Reload
18-
- Easily expandable
19+
- Easily extendable
1920

2021
## System requirements
2122
- Node.js
@@ -61,16 +62,28 @@ $ yarn deploy:live
6162
| dev | bundle and watch for changes in `src/` files with webpack |
6263
| build | create dist files for Shopify in `shopify/assets/` directory with webpack |
6364
| reloadr | run a http server and websocket server for remote auto reloading |
64-
| lint | lint `js` and `vue` files inside the`src/` directory |
65+
| lint | lint `js` and `vue` files inside the `src/` directory |
6566
| shopify:watch | watch for changes in the `shopify/` directory and upload to the dev store |
66-
| shopify:init | initializes theme on remote shopware store and creates a shopify config file for specified environment |
67+
| shopify:init | initialize theme on remote shopware store and create a shopify config file for specified environment |
6768
| deploy:dev | upload the `shopify/` directory to the dev store |
6869
| deploy:live | upload the `shopify/` directory to the live store |
6970
| settings:dev | download `settings_data.json` from dev store |
7071
| settings:live | download `settings_data.json` from live store |
7172
| open:dev | open the url of the dev store |
7273
| open:live | open the url of the live store |
7374

75+
## Development environment concepts
76+
- By running `shopify:init` and entering credentials, the task initializes a new theme from `shopify/` directory to the provided Shopify store. It also saves a configuration file for the specified environment inside `.config/shopify/` directory. This file will be ignored by git and shouldn't be tracked for security reasons. All tasks regarding Shopify will use the credentials from the saved configuration file.
77+
- By running `yarn start` 3 tasks are executed in parallel: `dev`, `reloadr` and `shopify:watch`.
78+
- Inside the `src/` directory are: a tailwind config, scss files and vue related files.
79+
- All vue related files are auto-loaded by webpack with [require.context](https://webpack.js.org/guides/dependency-management/#requirecontext) - vue components, vuex modules, mixins with `global` in their filename and directives with `global` in their filename.
80+
- Vue components can be either used as regular single-file-components or as [renderless components](https://css-tricks.com/building-renderless-vue-components) without `<template></template>` tags.
81+
- The webpack bundle and all other assets are outputted to `shopify/assets` directory.
82+
- The `shopify/` directory is being watched for changes and all changed files are uploaded to the Shopify remote server. After the upload is finished, a request is sent to a localhost:port address and the [reloadr script](.config/reloadr/) reloads the remote store (if it's open in the browser).
83+
84+
<img width="100%" src=".config/.readme/auto-reload-demo.gif" alt="Shopify Starterkit auto reload demo">
85+
7486
## Limitations
75-
- Vue components can only be used in `<kebab-case />`
76-
- `<style></style>` will be removed on mount inside vue components (basically everything inside #app), use `<component is="style"><componet>` instead
87+
- Already running Shopify tasks only upload files which are changed, a simple re-save of a file, without editing it, won't upload the file to the remote store
88+
- Vue components inside `.liquid` files can only be used in a non-self-closing `<kebab-case></kebap-case>` manner
89+
- `<style></style>` will be removed on mount inside vue components (basically everything inside #app), use `<component is="style"><componet>` instead when working with `.liquid` files

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "shopify-starterkit",
33
"description": "Environment for rapid Shopify theme development with Vue and Tailwind CSS",
44
"author": "Sergej Samsonenko",
5-
"version": "1.1.1",
5+
"version": "1.2.0",
66
"license": "MIT",
77
"repository": {
88
"type": "git",
@@ -36,7 +36,7 @@
3636
},
3737
"dependencies": {
3838
"axios": "^0.20.0",
39-
"tailwindcss": "^1.8.9",
39+
"tailwindcss": "^1.8.10",
4040
"vue": "^2.6.12",
4141
"vuex": "^3.5.1"
4242
},

shopify/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Docs
2-
- Template files from [repo](https://github.com/Shopify/themekit/tree/master/theme-template/templates)
3-
- Subdirectories are not allowed
2+
- Subdirectories are not allowed (Shopify limitation)
3+
- Template files are from themekit [repo](https://github.com/Shopify/themekit/tree/master/theme-template/templates)
4+
- More code and examples can be found in the official Shopify starter-theme [repo](https://github.com/Shopify/starter-theme/tree/master/src)
45

56
## Overview
67
- [Concepts](https://shopify.dev/concepts)

shopify/layout/theme.liquid

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
<link rel="canonical" href="{{ canonical_url }}">
1616
{% endif %}
1717

18-
{% comment %} css bundle is not loaded during development task {% endcomment %}
18+
{% comment %}
19+
css bundle is not loaded during development task, instead it displays a 404 error in the web console
20+
{% endcomment %}
1921
{{ 'bundle.css' | asset_url | stylesheet_tag }}
2022

2123
<!-- Header hook for plugins -->
@@ -29,17 +31,44 @@
2931
<div id="app" class="min-h-screen flex flex-col">
3032
{% section 'header' %}
3133

34+
{% comment %}
35+
vue component: with shopify data passed via prop
36+
{% endcomment%}
37+
<render-system-info
38+
:shopify-data="{
39+
shopName: '{{ shop.name }}',
40+
shopDomain: '{{ shop.domain }}',
41+
shopEmail: '{{ shop.email }}',
42+
shopCurrency: '{{ shop.currency }}'
43+
}"
44+
class="container mb-8"
45+
>
46+
<div class="text-lg font-bold mb-4">
47+
System Info
48+
</div>
49+
</render-system-info>
50+
3251
<main class="flex-1 container" role="main">
3352
{{ content_for_layout }}
3453
</main>
3554

3655
{% section 'footer' %}
3756

57+
{% comment %}
58+
renderless vue component: snippets/vue-offcanvas.liquid
59+
test it by clicking the hamburger-menu icon on mobile breakpoint
60+
{% endcomment%}
3861
{% render 'vue-offcanvas' %}
39-
<render-backdrop class="bg-black bg-opacity-50" />
62+
63+
{% comment %}
64+
vue component
65+
{% endcomment%}
66+
<render-backdrop class="bg-black bg-opacity-50"></render-backdrop>
4067
</div>
4168

42-
<!-- js bundle -->
69+
{% comment %}
70+
js bundle outputted by webpack
71+
{% endcomment%}
4372
{{ 'bundle.js' | asset_url | script_tag }}
4473
</body>
4574
</html>

shopify/locales/de.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"customer": {
1616
"account": "Konto",
1717
"log_in": "Anmelden",
18-
"log_out": "Abmelden",
18+
"logout": "Abmelden",
1919
"register": "Registrieren"
2020
}
2121
}

shopify/locales/en.default.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"customer": {
1616
"account": "Account",
1717
"log_in": "Log in",
18-
"log_out": "Log out",
18+
"logout": "Log out",
1919
"register": "Register"
2020
}
2121
}

0 commit comments

Comments
 (0)