From ef194d028e62a0c9b4def4ee9e5de11e185d2b34 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 25 Oct 2015 01:00:00 +0300 Subject: minify css/js from gradle --- build.gradle | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/build.gradle b/build.gradle index f0d69376..0e204f80 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,21 @@ subprojects { } } +buildscript { + repositories { + mavenCentral() + jcenter() + } + dependencies { + classpath 'com.eriwen:gradle-css-plugin:1.11.1' + classpath 'com.eriwen:gradle-js-plugin:1.12.1' + } +} + apply plugin: 'war' apply plugin: 'jetty' +apply plugin: 'css' +apply plugin: 'com.eriwen.gradle.js' repositories { mavenCentral() @@ -36,4 +49,46 @@ dependencies { providedCompile 'javax.servlet:javax.servlet-api:3.1.0' } +javascript.source { + dev { + js { + srcDir "src/main/webapp" + include "*.js" + } + } +} + +combineJs { + source = javascript.source.dev.js.files + dest = file("${buildDir}/scripts.all.js") +} + +minifyJs { + source = combineJs + dest = file("${buildDir}/scripts.min.js") + sourceMap = file("${buildDir}/scripts.sourcemap.json") +} + +css.source { + dev { + css { + srcDir "src/main/webapp" + include "*.css" + } + } +} + +combineCss { + source = css.source.dev.css.files + dest = "${buildDir}/style.all.css" +} + +minifyCss { + source = combineCss + dest = "${buildDir}/style.min.css" +} + +assemble.dependsOn 'minifyCss' +assemble.dependsOn 'minifyJs' + jettyRun.contextPath = '' -- cgit v1.2.3