Spring Download with Gradle and Webpack

I have an application written using Spring Boot and JS on the client. All JS and CSS codes are stored in src/main/webappand compiled using Webpack into the same directory. It seems dirty to put the compiled package there, but I wonder if there is a way to save it in the build directory?

I managed to add it to the war file using the following code in build.gradle

from("${buildDir}") {
    include 'bundle.js'
}

But I have no sense how to achieve the same effect for the bootRun task or in Intellij Idea.

Also, how can I exclude the source files stored in src/main/webapp/jsand src/main/webapp/scss? And what are the best practices for managing network resources?

+4
source share
2 answers

You should probably take a look at Jhipster ( http://jhipster.imtqy.com/ )

By the way, for my projects, I clearly prefer to separate client code from server code. The project-client directory for the JS code, next to the project-server directory with Java code.

The first has obviously a “standard Java file structure”.

For the first, JS has its own standards. Well, they are not very stable;), but still. Your JS source code may be half or more - your source, its place is probably not in a subdirectory of your Java project ...

, , Webpack, . Webpack , , . // , Java.

webpack. index.html( Java-) localhost: [webpack-port]/main.js

, Gradle. Gradle NPM ( https://github.com/srs/gradle-node-plugin) JS-, Java. javascript . JS , , ! - conf, Java.

0

node_modules webapp. build.gradle

sourceSets {
main {
    resources {
        exclude '**/node_modules'
    }

   }
}

, .

+1

Source: https://habr.com/ru/post/1618705/


All Articles