Gradle plugin for working with JS
Aiming to be the simplest way to manage your JavaScript in a build.
Wrangling your JS in a Gradle build is easy! Just add this to your build.gradle file:
plugins {
id "com.eriwen.gradle.js" version "2.14.1"
}buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.eriwen:gradle-js-plugin:1.12.1"
}
}
apply plugin: "com.eriwen.gradle.js"// Declare your sources
javascript.source {
dev {
js {
srcDir jsSrcDir
include "*.js"
exclude "*.min.js"
}
}
prod {
js {
srcDir jsSrcDir
include "*.min.js"
}
}
}// Configure the built-in task
combineJs {
encoding = "UTF-8"
source = javascript.source.dev.js.files
dest = file("${buildDir}/all.js")
}
// Create new CombineJsTasks if you have multiple sets of JS files
task jsDev(type: com.eriwen.gradle.js.tasks.CombineJsTask) {
source = ["${projectDir}/js/file1.js", "${projectDir}/js/file2.js"]
dest = file("${buildDir}/all-debug.js")
}
task jsProd(type: com.eriwen.gradle.js.tasks.CombineJsTask) {
source = ["${projectDir}/js/file1.js", "${projectDir}/js/file2.js"]
dest = file("${buildDir}/all.js")
}minifyJs {
source = combineJs
dest = file("${buildDir}/all-min.js")
sourceMap = file("${buildDir}/all.sourcemap.json")
closure {
warningLevel = 'QUIET'
}
}gzipJs {
source = minifyjs
dest = file("${buildDir}/all-min.js")
}jshint {
source = javascript.source.dev.js.files
dest = file("${buildDir}/jshint.out")
reporter = 'checkstyle'
jshint.options = [expr: "true", unused: "true"]
}jsdoc {
source = ["${projectDir}/js/file1.js", "${projectDir}/js/file2.js"]
destinationDir = file("${buildDir}/jsdoc")
}props2js {
source = file("${projectDir}/src/test/resources/test.properties")
dest = file("${buildDir}/props.jsonp")
props {
type = 'jsonp'
functionName = 'fn'
}
}requireJs {
source = javascript.source.dev.js.files
dest = file("${buildDir}/out.js")
requirejs.buildprofile = new File("src/main/resources/requirejs-config.js")
}false and jshint finds problems. Default is true.true will output to STDOUT instead of file. Default is false.[expr: "true", unused: "true"])…requirejs.options) requirejs.buildprofile = File reference for config examplefalse and require.js did not run successfully. Default is false.What, you want more? Tell me!
This project is made possible due to the efforts of these fine people:
The Gradle CSS Plugin!
No open issues yet, or sync has not completed.