Skip to content

Commit 9c5a064

Browse files
authored
Merge pull request #118 from uicrooks/dev
v4.1.1
2 parents 9b37659 + 27217f0 commit 9c5a064

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "shopify-theme-lab",
33
"description": "Customizable modular development environment for blazing-fast Shopify theme creation",
44
"author": "Sergej Samsonenko",
5-
"version": "4.1.0",
5+
"version": "4.1.1",
66
"license": "MIT",
77
"scripts": {
88
"start": "run-p -sr shopify:serve webpack:watch",
@@ -29,16 +29,16 @@
2929
"devDependencies": {
3030
"@babel/core": "^7.14.8",
3131
"@babel/plugin-transform-runtime": "^7.14.5",
32-
"@babel/preset-env": "^7.14.8",
32+
"@babel/preset-env": "^7.14.9",
3333
"@vue/compiler-sfc": "^3.1.5",
3434
"autoprefixer": "^10.3.1",
3535
"babel-loader": "^8.2.2",
3636
"clean-webpack-plugin": "^3.0.0",
3737
"cross-env": "^7.0.3",
3838
"css-loader": "^6.2.0",
3939
"css-minimizer-webpack-plugin": "^3.0.2",
40-
"eslint": "^7.31.0",
41-
"eslint-plugin-vue": "^7.14.0",
40+
"eslint": "^7.32.0",
41+
"eslint-plugin-vue": "^7.15.0",
4242
"eslint-webpack-plugin": "^3.0.1",
4343
"mini-css-extract-plugin": "^2.1.0",
4444
"npm-run-all": "^4.1.5",
@@ -50,8 +50,8 @@
5050
"stylelint-config-recommended": "^5.0.0",
5151
"stylelint-webpack-plugin": "^3.0.1",
5252
"url-loader": "^4.1.1",
53-
"vue-loader": "^16.3.1",
54-
"webpack": "^5.46.0",
53+
"vue-loader": "^16.4.1",
54+
"webpack": "^5.48.0",
5555
"webpack-cli": "^4.7.2",
5656
"webpack-merge": "^5.8.0"
5757
}

src/main.js

+22-7
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,31 @@ const createVueApp = () => {
8383
createVueApp().mount('#app')
8484

8585
/**
86-
* fix: properly render vue components inside sections on user insert in the theme editor
87-
* add the 'vue' keyword to the section's wrapper classes e.g.:
86+
* fixes for Shopify sections
87+
* 1. properly render vue components on user insert in the theme editor
88+
* 2. reload the current page to rerender async inserted sections with vue components
89+
*
90+
* add the 'vue' keyword to the section's wrapper classes if the section uses any vue functionality e.g.:
8891
* {% schema %}
8992
* {
9093
* "class": "vue-section"
9194
* }
9295
* {% endschema %}
9396
*/
94-
Shopify.designMode && document.addEventListener('shopify:section:load', (event) => {
95-
if (event.target.classList.value.includes('vue')) {
96-
createVueApp().mount(event.target)
97-
}
98-
})
97+
if (Shopify.designMode) {
98+
document.addEventListener('shopify:section:load', (event) => {
99+
if (event.target.classList.value.includes('vue')) {
100+
createVueApp().mount(event.target)
101+
}
102+
})
103+
} else if (!Shopify.designMode && process.env.NODE_ENV === 'development') {
104+
new MutationObserver((mutationsList) => {
105+
mutationsList.forEach(record => {
106+
const vue = Array.from(record.addedNodes).find(node => node.classList && node.classList.value.includes('vue'))
107+
if (vue) window.location.reload()
108+
})
109+
}).observe(document.body, {
110+
childList: true,
111+
subtree: true
112+
})
113+
}

0 commit comments

Comments
 (0)