Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new plugin for sass pipeline using dart-sass JS compiler #290

Merged
merged 7 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ asset-pipeline-site/src/assets/html/apidoc/
.jruby-container
.sass-cache
.sass-work
.shelf/
2 changes: 2 additions & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
gradle=6.5
java=8.0.312-zulu
3,415 changes: 3,352 additions & 63 deletions asset-pipeline-core.ipr

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ interface AssetPipelineExtension {
@Input
@Optional
List<String> getResolvers()
void setResolvers(List value)
void setResolvers(List<String> value)

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AssetPipelinePlugin implements Plugin<Project> {

def defaultConfiguration = project.extensions.create('assets', AssetPipelineExtensionImpl)
def config = AssetPipelineConfigHolder.config != null ? AssetPipelineConfigHolder.config : [:]
config.cacheLocation = "${project.buildDir}/.assCache"
config.cacheLocation = "${project.buildDir}/.assetcache"
if (project.extensions.findByName('grails')) {

defaultConfiguration.assetsPath = 'grails-app/assets'
Expand Down
4 changes: 2 additions & 2 deletions asset-pipeline-micronaut/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ dependencies {
testImplementation("org.spockframework:spock-core:1.1-groovy-2.4") {
exclude module:'groovy-all'
}
testImplementation "io.micronaut:http-client:${micronautVersion}"
testImplementation "io.micronaut:inject-groovy:${micronautVersion}"
// testImplementation "io.micronaut:http-client:${micronautVersion}"
// testImplementation "io.micronaut:inject-groovy:${micronautVersion}"
runtimeOnly "ch.qos.logback:logback-classic:1.2.3"
}

Expand Down
64 changes: 36 additions & 28 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,45 @@ ext {
group = 'com.bertramlabs.plugins'

repositories {
jcenter()
mavenCentral()
}

if (isReleaseVersion) {
apply plugin: "io.github.gradle-nexus.publish-plugin"
nexusPublishing {
repositories {
sonatype {
if(project.hasProperty('mavenUser')) {
username = mavenUser
password = mavenPassword
}
}
}
}
} else {

publishing {
repositories {
maven {
url = "http://nexus.bertramlabs.com/content/repositories/snapshots"
if(project.hasProperty('labsNexusUser')) {
credentials {
username = labsNexusUser
password = labsNexusPassword
}
}
}
}
}
java {
withJavadocJar()
withSourcesJar()
}

//if (isReleaseVersion) {
// apply plugin: "io.github.gradle-nexus.publish-plugin"
// nexusPublishing {
// repositories {
// sonatype {
// if(project.hasProperty('mavenUser')) {
// username = mavenUser
// password = mavenPassword
// }
// }
// }
// }
//} else {

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
maven {
url = project.hasProperty('labsNexusUrl') ? labsNexusUrl : "https://nexus.bertramlabs.com/content/repositories/snapshots"
if(project.hasProperty('labsNexusUser')) {
credentials {
username = labsNexusUser
password = labsNexusPassword
}
}
}
}
}

subprojects { project ->
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
version=3.3.6
version=3.3.6.TRITON.2
org.gradle.warning.mode=none
3 changes: 3 additions & 0 deletions sass-dart-asset-pipeline/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
src/main/resources/js/
javet-version.txt
13 changes: 13 additions & 0 deletions sass-dart-asset-pipeline/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2016 Gabriel Féron

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
64 changes: 64 additions & 0 deletions sass-dart-asset-pipeline/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
SASS Asset Pipeline
==========================
The `sass-dart-asset-pipeline` is a plugin that provides SASS / SCSS support for the asset-pipeline static asset management plugin using the [dart-sass](https://sass-lang.com/dart-sass) native JS compiler.

The plugin uses [Javet](https://www.caoccao.com/Javet/) (based on Google's V8 runtime) to allow for execution of the dart-sass JS compiler directly from Java.

For more information on how to use asset-pipeline, visit [here](http://www.github.com/bertramdev/asset-pipeline).

Integration
===========
Javet requires native libraries for integration. The first time you execute the pipeline, the appropriate native library will be downloaded for your platform. The supported
platforms are:

* Linux - x86_64
* Windows - x86_64
* MacOS - x86_64, arm64

The platform JAR is downloaded by default from Maven Central to the Java system temp directory. You can
override this behavior by setting the following options:

* javetBaseUrl = "https://repo1.maven.org/maven2/com/caoccao/javet" (default)
* javetLibraryHome = System.getProperty('java.io.tmpdir') (default)

If the native library already exists at `javetLibraryHome` it will not be downloaded again.

The full platform URL is constructed from the `javetBaseUrl`.

For example, on Mac OS, it would look like this:

`"${javetBaseUrl}/javet-macos/1.0.6/javet-macos-1.0.6.jar"`

Configuration
-------------
Configuration is passed through to the dart-sass compiler:

https://sass-lang.com/documentation/js-api/interfaces/LegacyStringOptions

Common options are:

* sass.outputStyle = "expanded" | "compressed" (default: "expanded")
* sass.indentType = "space" | "tab" (default "space")
* sass.indentWidth = 0..10 (default: 2)
* sass.quietDeps = boolean (default: false) - Don't report deprecation warnings for imported files

For example:
```
assets {
configOptions = [
javetBaseUrl: 'https://myrepo.mycompany.com/repository/com/caoccao/javet'
sass: [
quietDeps: true,
outputStyle: 'compressed'
]
]
}
```

Usage
-----
Simply create `scss` or `sass` files in your assets folder.

Things to be done
-----------------
* Find a way to generate proper source maps with full paths
1 change: 1 addition & 0 deletions sass-dart-asset-pipeline/assets/stylesheets/_bar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.bar {color: red;}
Loading