5

I'm starting to get into web development a little more. Currently I use the Spark Framework along with Vue for the few apps I've made. While this certainly works it's not ideal.

The project is built with Maven (and NPM for Vue) and the build process looks something like this.

  1. Maven packages the Spark Framework Java application
  2. Maven (with the frontend-maven-plugin) downloads node/npm and builds the Vue frontend
  3. Maven copies the compiled resources into the jar as static assets

So the filesystem looks something like this

/src/main/java (Spark Framework)

/src/main/resources (Vue)

This leads to a couple of annoyances.

  1. Everything is in one repository. Ideally I'd be able to have a separate repo for each layer of the project (One for Java, one for Vue)
  2. Development workflow isn't ideal. If I just want to test the Java part of the app, I still spend time compiling the frontend (Vue)
  3. A minor issue, but while working in an IDE, I'm dealing with deeply nested folders. Anytime I want to edit the frontend, my folder structure looks something like /src/main/resources/project-vue/

Here's one of my projects that uses this model

So my question is: What's a better way to structure my application?

4

1 回答 1

2

我有几个月的时间来思考,在那段时间里,我用 Vue 创建了更多的应用程序,这是我开始采用的工作流程。

我为任何具有多个层的项目创建一个 GitHub 组织。例如,我的许多项目都有一个用 Java 或 JavaScript 编写的 REST API,以及一个使用 Vue 的 Web 界面。该组织将包含每个层的存储库。这是一个遵循这个想法的组织的链接。

这使我可以将后端和前端分开,但部署起来很复杂。我不能再使用与 API 相同的 Web 服务器来提供我的 Vue 文件,但进一步认为这可能是一件好事。

使用这种模式,我可以在非常便宜的 Amazon S3 上托管我的静态 Vue 站点,并使用带有 Heroku 的免费 dynos 来托管我的 API。

于 2018-04-02T18:44:54.007 回答