Maybe you can be the savior of my day.
I'm trying to implement vue-components to my extension.
I can not include custom Vue.js components. I followed https://pagekit.com/docs/developer-basics/vuejs-and-webpack to create a component that should provide a modal-field that should be included to the settings-view of my extension. This modal should be used multiple times on the same page with different contents, so I would prefer using a custom component instead of hard-coding it over and over again to the settings-view (views/settings.php
).
To archive this I created the following file: app/components/template.vue
<template>
<div>Test</div>
</template>
<script>
module.exports = {
section: {
label: 'Template',
priority: 100
}
};
window.Settings.components['template'] = module.exports;
</script>
I also updated the webpack.config.js
module.exports = [
{
entry: {
"settings": "./app/views/admin/settings",
"template": "./app/components/template.vue"
},
output: {
filename: "./app/bundle/[name].js"
},
module: {
loaders: [
{test: /\.vue$/, loader: "vue"}
]
}
}
];
and I registered the component in the index.php
'events' => [
'view.scripts' => function ( $event, $scripts ) {
$scripts->register( 'template', 'isp:app/bundle/template.js', '~settings' );
}
]
Now I try to get the things working in the view
$view->script( 'settings', 'isp:app/bundle/settings.js', [ 'vue', 'uikit-form-password', 'editor' ] )
;
<component :is="template"></component>
But the Test-string is not shown