Build webpack using this plugin
testinggithub1222 opened this issue · 4 comments
I am trying to use this plugin to work with npm as well as webpack in other to build reactjs web application but I am not sure how can i build webpack using this plugin. What I can find is build npm only.
I have found some same question on stackoverflow but i could not find any solution. Please help me find out.
plugins {
id 'org.springframework.boot' version '2.2.0.M1'
id 'java'
id "com.moowork.node" version "1.3.1"
}
apply plugin: 'io.spring.dependency-management'
group = 'com.test'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/snapshot' }
maven { url 'https://repo.spring.io/milestone' }
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
node {
version = '10.15.3'
npmVersion = '3.10.6'
download = true
workDir = file("${project.buildDir}/node")
nodeModulesDir = file("${project.projectDir}")
}
// Runs "npm run build" to build the app.
task nodeBuild(type: NpmTask) {
args = ['run', 'build', 'webpack', 'build']
}
jar {
from ("dist/")
includeEmptyDirs = true
}
// Deletes the "dist" folder containing the result of the build process.
clean {
delete 'dist/'
}
build.dependsOn(npm_install)
In case of args = ['run', 'build']
you need to have corresponding build
in scripts
section of package.json
. No need to put anything except this in gradle configuration
@vitalyster Please elaborate in detail i am not sure what do you mean by this.
Here is a part of your gradle configuration:
// Runs "npm run build" to build the app.
task nodeBuild(type: NpmTask) {
args = ['run', 'build', 'webpack', 'build']
}
just remove unnecessary args and make it looks like that:
args = ['run', 'build']
then check your package.json
for the scripts
section, it should have the following:
"scripts": {
"build": "webpack build"
}
So gradle node plugin will run npm build
task and it will call webpack build
script
@vitalyster sorry for late reply. I will check it out and report as soon as i got time and test it.