-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathbuild.gradle
68 lines (62 loc) · 2.6 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* This software is in the public domain under CC0 1.0 Universal plus a
* Grant of Patent License.
*
* To the extent possible under law, the author(s) have dedicated all
* copyright and related and neighboring rights to this software to the
* public domain worldwide. This software is distributed without any
* warranty.
*
* You should have received a copy of the CC0 Public Domain Dedication
* along with this software (see the LICENSE.md file). If not, see
* <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
import java.nio.charset.StandardCharsets
buildscript {
repositories {
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "org.gradle-webtools.minify:gradle-minify-plugin:1.3.1"
}
}
apply plugin: "org.gradlewebtools.minify"
def compsPath = "screen/store/components"
// source JS files in load order
def compsJsFiles = [compsPath + "/utilities.js", compsPath + "/ApiServices.js", compsPath + "/ComponentsNav.js",
compsPath + "/ComponentsProduct.js", compsPath + "/ComponentsAccount.js", compsPath + "/ComponentsCheckout.js", compsPath + "/main.js"]
task combineBaseJs {
doLast {
def destFile = file("${compsPath}/combined.js")
destFile.write("")
compsJsFiles.each({
destFile.append(file(it).getText("UTF-8"), "UTF-8")
destFile.append("\n")
})
}
}
task minifyCombined(type: org.gradlewebtools.minify.JsMinifyTask) {
dependsOn combineBaseJs
// see: https://github.com/gradle-webtools/gradle-minify-plugin
// NOTE: JsMinifyTask (and the css one, etc) always recursively minify in sub-directories, no way to disable! (based on source review 2022-04-05)
srcDir = file(compsPath)
dstDir = file(compsPath)
options.ignoreMinFiles = true
options.emitUseStrict = false
options.strictModeInput = false
options.compilationLevel = com.google.javascript.jscomp.CompilationLevel.SIMPLE_OPTIMIZATIONS
options.env = com.google.javascript.jscomp.CompilerOptions.Environment.BROWSER
options.warningLevel = com.google.javascript.jscomp.WarningLevel.QUIET
options.charset = StandardCharsets.UTF_8
// options.outputCharset = StandardCharsets.UTF_8
options.setLanguageIn(com.google.javascript.jscomp.CompilerOptions.LanguageMode.fromString("ECMASCRIPT6"))
options.setLanguageOut(com.google.javascript.jscomp.CompilerOptions.LanguageMode.fromString("ES5"))
}
task clean { doLast {
delete fileTree(dir: compsPath, include: 'combined.*')
delete fileTree(dir: compsPath, include: '*.min.js')
}}
task build {
dependsOn minifyCombined
}