Skip to content

Commit

Permalink
Issue bertramdev#287: Cleanup build; Pass through compiler options; F…
Browse files Browse the repository at this point in the history
…ix README.md; more testing
  • Loading branch information
longwa committed Dec 9, 2021
1 parent 9700d91 commit a4a0c29
Show file tree
Hide file tree
Showing 10 changed files with 1,685 additions and 25 deletions.
1 change: 1 addition & 0 deletions asset-pipeline-core.ipr
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="GrMethodMayBeStatic" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="GrazieInspection" enabled="false" level="TYPO" enabled_by_default="false" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
Expand Down
54 changes: 47 additions & 7 deletions sass-dart-asset-pipeline/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,64 @@
SASS Asset Pipeline
==========================
The `sass-asset-pipeline` is a plugin that provides SASS / SCSS support for the asset-pipeline static asset management plugin using [jsass](https://github.com/bit3/jsass), a Java wrapper around the native library [libsass](https://github.com/sass/libsass) - the future of Sass compilation.
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 version numbering is synced on [jsass](https://github.com/bit3/jsass) versions, the underlying library used by this plugin.
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

Configuration is only supported for two properties:
* sass.sourceComments = true
* sass.outputStyle = OutputStyle.EXPANDED, OutputStyle.COMPACT, OutputStyle.COMPRESSED or OutputStyle.NESTED
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
-----------------

* Add more configuration options
* Find a way to generate proper source maps with full paths
11 changes: 10 additions & 1 deletion sass-dart-asset-pipeline/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,16 @@ task copyJavetVersion() {
}
}

compileGroovy.dependsOn copyJavetVersion
task bundleJSCompiler(type: NpmTask, dependsOn: ['npmInstall']) {
doFirst {
mkdir('src/main/resources/js')
}
inputs.files(fileTree('src/main/js'), file('webpack.config.js'))
outputs.file('src/main/resources/js/compiler.js')
args = ['run', 'bundle']
}

compileGroovy.dependsOn copyJavetVersion, bundleJSCompiler

task(console, dependsOn: 'classes', type: JavaExec) {
main = 'groovy.ui.Console'
Expand Down
Loading

0 comments on commit a4a0c29

Please sign in to comment.