I'm slowly migrating a legacy PHP app to Vue. An initial step is to have the PHP script point to a webpack dev server so that all the nice features of the vue-cli can be used. What this looks like is:
index.php
<?php
require_once("very_complicated_file.php");
require_once("other_complicated_file.php");
?>
//some js scripts/libraries that are required for the vue app to work, and used elsewhere in the PHP app
<script src="..." />
<script src="....." />
??? //<-------
<?php
//some more other hard-to-factor-out-php that is needed for the vue app
?>
The thing that is most confusing to me right now is when I have my vue-cli/webpack-dev-server running (on the same server as the PHP), what should this web page request from the server to get all the needed files to run the vue app? The confusing part to me is that the webpack dev server doesn't actually save any files to the filesystem in the dev environment, so I don't know what to request. For example, in prod, I just requestapp.js
and that's all I need. However, here, it's unclear how to connect the files delivered by webpack dev server to the rendered PHP script. Another hole in my knowledge is also how HMR works with this setup. Does the JS delivered by the dev server magically contain HMR reloading code that's injected by the vue-cli build system? Another way of phrasing this question might be: how can I explicitly import all the assets that are delivered by webpack dev server, that are served by default in a normal/stock vue-cli project setup?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
JavaScript is a multi-paradigm language that supports event-driven, functional, and mandatory (including object-oriented and prototype-based) programming types. Originally JavaScript was only used on the client side. JavaScript is now still used as a server-side programming language. To summarize, we can say that JavaScript is the language of the Internet.
https://www.javascript.com/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.