在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):houbie/lesscss-gradle-plugin开源软件地址(OpenSource Url):https://github.com/houbie/lesscss-gradle-plugin开源编程语言(OpenSource Language):Groovy 97.1%开源软件介绍(OpenSource Introduction):LESS CSS Gradle Plugin
A gradle plugin for compiling LESS to CSS, compatible with less v1.7.0 FeaturesThe plugin is based on lesscss, which:
InstallationThe plugin is available in the maven central repository. You can add it to your gradle build as follows: buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.github.houbie:lesscss-gradle-plugin:1.0.3-less-1.7.0"
}
}
apply plugin: "lesscss" lessc taskThe plugin adds a lessc task that requires a lessc {
sourceDir "customized/less", "standard/less"
include "**/*.less", "**/*.js"
exclude "imports/**/*"
destinationDir = "$buildDir/css"
}
ConfigurationThe lesscss plugin supports all the options of the standard less: lessc {
//plugin configuration
////////////////////////
engine = "commandline" //Either 'rhino', 'nashorn' (requires jdk8) or 'commandline' (requires local node.js). Default: 'rhino'
lesscExecutable = "$userHome\\AppData\\Roaming\\npm\\lessc.cmd" //The executable to use for the commandline engine. Default: 'lessc' (typically OK on UN*X)
customJavaScript = file("custom.js").text //javascript that can provide functions to the less compiler. Default: null
encoding = "utf-8" //encoding used to read less files. Default: null (platform encoding)
//standard LESS options
/////////////////////////
options.compress = true //Compress output by removing some whitespaces. Default: false
options.strictImports = true //Force evaluation of imports. Default: false
options.rootpath = /root/path //Set rootpath for url rewriting in relative imports and urls. Works with or without the relative-urls option. Default: null
options.relativeUrls = true //Re-write relative urls to the base less file. Default: false
options.minify = true //Compress output using YUI minifier (standard LESS uses clean-css, which is only available in node.js). Default: false
options.strictMath = true //In strict mode, math requires brackets. Default: false
options.strictUnits = true //Disallow mixed units, e.g. 1px+1em or 1px*1px which have units that cannot be represented. Default: false
options.ieCompat = false //Enable IE compatibility checks. Default: true
options.javascriptEnabled = false //Enable JavaScript in less files. Default: true
options.sourceMap = true //Outputs a v3 sourcemap. Default: false
options.sourceMapRootpath = "/path/to/sourcemaps" //adds this path onto the sourcemap filename and less file paths. Default: null
options.sourceMapBasepath = file("$buildDir/css").absolutePath //Sets sourcemap base path (will be subtracted from generated paths). Default: null
options.sourceMapLessInline = true //Puts the less files into the map instead of referencing them. Default: false
options.sourceMapMapInline = true //Puts the map (and any less files) into the output css file. Default: false
options.sourceMapURL = "http://localhost:8080/myApp/css/source.map" //The complete url and filename put in the less file. Default: null (calculated)
options.globalVars = [fancyColor: "#123456"] //Defines a variable that can be referenced in the less. Default: empty Map
options.modifyVars = ["btn-warning-bg": "red"] //Modifies a variable already declared in the less. Default: empty Map
//deprecated options
options.optimizationLevel = 1 //Set the parser's optimization level. The lower the number, the less nodes it will create in the tree
options.dumpLineNumbers= NONE //Outputs filename and line numbers in comments (COMMENTS) or in a fake media query (MEDIA_QUERY). Use source maps instead.
}
Per file configurationWhen different less files require different options (f.e. source map options), they can be configured with a Example: lessc {
...
preCompile { FileTreeElement src, CompilationUnit unit ->
unit.destination = project.file("css/${src.name}-less.css")
unit.options.sourceMap = true
unit.sourceMapFile = project.file("css/${src.name}-less.map")
unit.options.sourceMapBasepath = unit.sourceMapFile.parentFile.absolutePath
}
}
lesscDaemon taskWhen running The gradle process keeps running until you hit the enter key.
The lesscDaemon has two configuration parameters: lesscDaemon {
lesscTaskName = "customLesscTask" //When you defined additional lessc tasks. Default: 'lessc'
interval = 200 //Scan interval in milliseconds. Default: 500
engine = "commandline"
lesscExecutable = "/opt/local/bin/lessc"
}
PerformanceThe supported engines perform quite different:
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论