Maven(在开发人员配置文件下运行)如何在index.html中包含javascript文件? [英] How does maven (running under dev profile) include the javascript files inside index.html?
问题描述
自2.0版以来,我还没有使用过jhipster,而我目前正在追赶#4.0.6版. 当我尝试从命令行通过"./mvnw"(默认为 dev maven配置文件)构建初始应用程序时,应用程序javascript文件未添加到index.html(因此该页面当我尝试 http://localhost:8080 时,在浏览器中显示为空白. 有人可以解释一下正常的事件链,这些事件通常会导致Maven(使用 dev 配置文件运行)将应用程序javascript文件包含到index.html中? 预先非常感谢您的帮助. 最好的祝福 kbjp
I haven't used jhipster since version 2.0 and I'm currently playing catch-up with version #4.0.6. When I try to build the initial app through "./mvnw" (with default dev maven profile) from the command line, the application javascript files are not added to the index.html (so that page comes up blank in my browser when I try http://localhost:8080). Could someone please explain me the normal chain of events which normally lead maven (running with the dev profile) to include the application javascript files into index.html ? Thank you very much in advance for your help. Best Regards kbjp
推荐答案
我们的工作流程如下,将根据选择使用yarn或npm
Our workflow is as below, yarn or npm will be used based on choice
- 生成应用程序时,将生成文件,并最终触发
yarn install
任务 -
package.json
中的postInstall
脚本在yarn install
之后触发,此步骤调用webpack:build
任务 - 现在您应该已经根据选定的构建工具将所有文件生成并编译到
target
或build
文件夹内的www
文件夹中 - 现在运行
mvnw
或gradlew
将启动后端,并且应在localhost:8080可用,这也应为通过上述步骤编译的前端提供服务 - 现在,如果您开始进行更改,则不会被反映为未编译状态,因此您需要在更改后手动运行
webpack:build:dev
或实时重新加载运行yarn start
- When you generate an app the files are generated and at the end it triggers
yarn install
task - The
postInstall
script inpackage.json
is triggered afteryarn install
, this step callswebpack:build
task - Now you should have all files generated and compiled into the
www
folder insidetarget
orbuild
folder based on build tool selected - Now running
mvnw
orgradlew
will launch the backend and should be available at localhost:8080 this should also serve the frontend compiled from above steps - Now if you start making changes nothing will be reflected as its not compiled so you need to either run
webpack:build:dev
manually after changes or haveyarn start
running with live reload
您要么不运行postInstall脚本,要么删除了目标文件夹
Either you didn't let the postInstall script run or you deleted the target folder
您还可以通过传递webpack
配置文件(如mvnw -Pdev,webpack
You can also force maven to run webpack task while starting by passing the webpack
profile like mvnw -Pdev,webpack
这篇关于Maven(在开发人员配置文件下运行)如何在index.html中包含javascript文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!