Skip to content

Commit 4a0522d

Browse files
committed
ISSUE-345: vue.js fix
1 parent 2622c68 commit 4a0522d

File tree

8 files changed

+23
-34
lines changed

8 files changed

+23
-34
lines changed

assets/app.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
import { createApp } from 'vue';
22
import App from './vue/App.vue';
3-
import MyWidget from './vue/MyWidget.vue';
43

54
// Mount the main app if the element exists
65
const appElement = document.getElementById('vue-app');
76
if (appElement) {
87
createApp(App).mount('#vue-app');
98
}
109

11-
// Mount the widget if the element exists
12-
const widgetElement = document.getElementById('my-widget');
13-
if (widgetElement) {
14-
createApp(MyWidget).mount('#my-widget');
15-
}

assets/vue/App.vue

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
<template>
22
<div>
3-
<h1>Hello from Vue!</h1>
3+
<h2>Hello from Vue</h2>
4+
<p>{{ message }}</p>
45
</div>
56
</template>
67

78
<script>
89
export default {
9-
name: 'App'
10+
name: 'App',
11+
data() {
12+
return {
13+
message: 'This is a reusable component!'
14+
}
15+
},
16+
created() {
17+
console.log('App component created');
18+
},
19+
mounted() {
20+
console.log('App component mounted');
21+
},
22+
updated() {
23+
console.log('App component updated');
24+
}
1025
}
1126
</script>

assets/vue/MyWidget.vue

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"webpack-notifier": "^1.15.0"
1313
},
1414
"dependencies": {
15-
"vue": "3"
15+
"vue": "^3.5.16"
1616
},
1717
"scripts": {
1818
"prepare": "husky install"

templates/base.html.twig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
{# Optionally include Bootstrap JS if you use interactive components #}
2020
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
2121
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
22-
{{ encore_entry_script_tags('app') }}
22+
<script src="{{ asset('build/runtime.js') }}"></script>
23+
<script src="{{ asset('build/app.js') }}"></script>
2324
</body>
2425
</html>

templates/security/login.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@
2525
<button type="submit" class="btn btn-primary btn-block">Sign in</button>
2626
</form>
2727
</div>
28-
<div id="my-widget"></div>
28+
<div id="vue-app"></div>
2929
{% endblock %}

webpack.config.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@ const Encore = require('@symfony/webpack-encore');
33
Encore
44
.setOutputPath('public/build/')
55
.setPublicPath('/build')
6-
.enableVueLoader()
76
.addEntry('app', './assets/app.js')
8-
.cleanupOutputBeforeBuild()
9-
.enableBuildNotifications()
10-
.enableSourceMaps(!Encore.isProduction())
11-
.enableVersioning(Encore.isProduction())
7+
.enableVueLoader()
128
.enableSingleRuntimeChunk()
139
;
1410

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2835,7 +2835,7 @@ vue-template-compiler@^2.7.14:
28352835
de-indent "^1.0.2"
28362836
he "^1.2.0"
28372837

2838-
vue@3:
2838+
vue@^3.5.16:
28392839
version "3.5.16"
28402840
resolved "https://registry.yarnpkg.com/vue/-/vue-3.5.16.tgz#f0cde88c2688354f00ff2d77eb295c26440f8c7a"
28412841
integrity sha512-rjOV2ecxMd5SiAmof2xzh2WxntRcigkX/He4YFJ6WdRvVUrbt6DxC1Iujh10XLl8xCDRDtGKMeO3D+pRQ1PP9w==

0 commit comments

Comments
 (0)