Maven(在开发人员配置文件下运行)如何在index.html中包含javascript文件? [英] How does maven (running under dev profile) include the javascript files inside index.html?

查看:112
本文介绍了Maven(在开发人员配置文件下运行)如何在index.html中包含javascript文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自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

  1. 生成应用程序时,将生成文件,并最终触发yarn install任务
  2. package.json中的postInstall脚本在yarn install之后触发,此步骤调用webpack:build任务
  3. 现在您应该已经根据选定的构建工具将所有文件生成并编译到targetbuild文件夹内的www文件夹中
  4. 现在运行mvnwgradlew将启动后端,并且应在localhost:8080可用,这也应为通过上述步骤编译的前端提供服务
  5. 现在,如果您开始进行更改,则不会被反映为未编译状态,因此您需要在更改后手动运行webpack:build:dev或实时重新加载运行yarn start
  1. When you generate an app the files are generated and at the end it triggers yarn install task
  2. The postInstall script in package.json is triggered after yarn install, this step calls webpack:build task
  3. Now you should have all files generated and compiled into the www folder inside target or build folder based on build tool selected
  4. Now running mvnw or gradlew will launch the backend and should be available at localhost:8080 this should also serve the frontend compiled from above steps
  5. 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 have yarn 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆