Skip to content

sschuberth/gradle-nodejs-plugin

 
 

Repository files navigation

Travis License Version

This plugin allows to use Node.js script and tools via gradle. NodeJs will be downloaded automatically and reused across execution.

Configuration

plugins {
    id "de.solugo.gradle.nodejs" version "..."
}

nodejs {
    version = '10.8.0'
    rootPath = 'subpath'
}

Task rules

Node

Run node script

gradle node<ScriptName> -Pargs="..." // node <script-name>.js <args>

Npm

Run npm script

gradle npm<TaskName> -Pargs="..." // npm <task-name> <args>

Yarn

Run yarn task

gradle yarn<TaskName> -Pargs="..." // yarn <task-name> <args>

Npx

Run node module

gradle npx<ModuleName> -Pargs="..." // npx <module-name>.js <args>

Tasks types

NodeJsTask

This task type enables you to create custom tasks using Node.js or common Node.js modules.

task("webpack", type: NodeJsTask) {
    require = ["webpack", "webpack-cli"]
    executable = "webpack-cli"
    args = ["--mode=production"]
}

Examples

Install development dependency using npm

gradle npmInstall -Pargs="--save-dev webpack"

Gradle Webpack Plugin

This plugin allows to use Webpack bundler via gradle. Webpack is automatically added to the processResources task.

Configuration

plugins {
    id "de.solugo.gradle.webpack" version "..."
}

Tasks

Webpack

Run node script

gradle webpack -Pargs="..." // webpack --mode=production <args>

Run node script

gradle webpackWatch -Pargs="..." // webpack --mode=development --watch <args>

About

Gradle plugin for node and npm scripts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Groovy 100.0%