-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an example of using Vue in the backend #102
Conversation
@hirisov this is a great start - well done! As a suggestion, I think a more applicable example would be to show how to use Vue for a backend controller inside a plugin. Would you be willing to adjust your example to show how to do this? Let me know if you need some help on what to say. |
@bennothommo thanks, you mean I should change it to include Vue in the plugin, and not the project's package json? Or you mean something else? :) |
@hirisov yeah, mainly just making sure that the entire tutorial manipulates files within the plugin, not in the root folder. Also, typically, we store asset files like JS and CSS within an |
Change JS source paths, move them to plugin's assets/ directory.
Update ToC
@bennothommo thanks, I updated it to move the src/ into assets/ and update the Table of contents part to include links to the examples. But I couldn't find a working way to define Vue 3 as a dependency in the plugin's package.json. If anybody can help me with that, I am glad to update it and use that method instead of the "npm install" way. |
@hirisov I generally just edit the "dependencies": {
"vue": "^3.2.41"
} And then run |
Update Vue example with local node packages in plugin's package.json.
@bennothommo thanks, I did the same but also defined vue-loader in package.json as dependency. That lead to an error during compiltion, but If I include only vue there as you suggested then all is good. I updated the PR with this. |
@hirisov the What sort of error did you get originally that didn't allow you to add Vue as a dependency in the plugin? We might need to check it out. |
@bennothommo the error on was my side, I included a mismatching version of the vue-loader alongside vue as devDependencies. If I include a matching version on vue-loader in the plugin's package.json, or don't include it at all just vue, in which case However I tried to improve the example to include another vue related package as an example to show how to work with other dependencies in plugin's package.json then I again ran into strange problems during |
@bennothommo so this is what happened in the next phase when I tried to include another vue package: 1, I choose https://antoniandre.github.io/splitpanes/ as a test as It supports vue3
So basically when I "originally" did If you want I can share the plugin code test. Maybe during development of the plugin "npm install" in the plugin directory isn't the correct way to add other node dependencies? |
Just as I sidenote, now it doesn't matter if I use |
@bennothommo I can make a PR to the wn-test-plugin to demonstrate this if you like, maybe it wouldn't be bad anyway to have a Vue (or in general package.json) example there? |
@bennothommo I made a PR for the test plugin to include the "base", working Vue with no other dependencies: https://github.com/wintercms/wn-test-plugin/pull/13/commits . Please let me know if you want to merge it, and then I will make another one demonstrating this issue with the other dependencies. If you don't think it should be merged then I will just make a new commit to that https://github.com/hirisov/wn-test-plugin to include the splitpanes to make it easier to test the problem. |
Co-authored-by: Luke Towers <[email protected]>
Co-authored-by: Luke Towers <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the feedback!
Thanks for this, @hirisov. I've cleaned up the docs a little and merged it. As for the problem that you encountered - I'm not sure TBH. My workflow tends to be:
For what it's worth, my root {
"devDependencies": {
"laravel-mix": "^6.0.41"
},
"workspaces": {
"packages": [
"modules/backend",
"modules/system"
]
}
} You'll notice that there's no dependencies in there (bar Laravel Mix), and everything is instead coming from the Backend and System modules. If I have a plugin or theme using Mix on that project, they will also be part of workspaces. |
@bennothommo thanks a lot for your clean up and the merge! Regarding the other problem, please let me know if I should proceed with the wintercms/wn-test-plugin#13 . If yes I will update the code there to follow these instructions that we finalized here, and after merging there I can make a new PR to demonstrate the problem. As I wrote after the backing up my test plugin and copying back to a fresh install there was no npm involved at all, just the package.json cointaining 2 lines (vue and splitpanes) and I did exactly what you wrote with
|
No worries - I'll give that a test and report back :) |
This is another example for using the laravel mix system. As we already have a nice example with Tailwind CSS, I think include an example for backend usage can be useful. I made the example with Vue 3, as I think that's a well known and popular framework.