【问题标题】:Use gradle to build front-end in Spring BootSpring Boot中使用gradle搭建前端
【发布时间】:2018-07-25 20:33:36
【问题描述】:

我的全栈 Spring boot + thymeleaf + react 中有以下设置

项目结构如下所示

build.gradle |src |main |java |resources index.js package.json build.gradle

我使用资源文件夹下的 gradle 脚本来构建前端 SPA。 脚本是这样的

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "com.moowork.gradle:gradle-node-plugin:1.2.0"
  }
}

apply plugin: "com.moowork.node"

task build(type: YarnTask) {
    args = ['run', 'build']
}
build.dependsOn('yarn_install')
task deleteModules(type: Delete) {
    delete "node_modules"
}
deleteModules.dependsOn('build')

以上构建将使用index.htmlindex.js 构建一个SPA

我的问题是,如何将它包含在顶级 build.gradle 中。这样每次构建java应用程序时,它都会先构建前端SPA

【问题讨论】:

    标签: java node.js spring-boot gradle


    【解决方案1】:

    我认为将前端的构建放在主 build.gradle 文件中会更好。

    例如像

    apply plugin: "com.moowork.node"
    
    task buildFrontend(type: YarnTask) {
        args = ['run', 'build']
    }
    tasks.build.dependsOn buildFrontend
    

    【讨论】:

    • 最终将所有构建放在主 gradle 文件中。为 gradle.node 配置路径非常令人困惑
    猜你喜欢
    • 1970-01-01
    • 2020-04-13
    • 2017-07-29
    • 2018-10-19
    • 2011-05-11
    • 2017-10-25
    • 2018-08-26
    • 2018-03-07
    • 1970-01-01
    相关资源
    最近更新 更多