This fork is mostly unchanged from craigbarnes/lua-sass except that it uses CMake for compilation and therefore gets Windows support for free.
Lua bindings for libsass.
First, clone this repository, making sure to initialize the submodule (git submodule update --init).
Open a command line in the lua-sass directory and do the following:
mkdir build
cd build
cmake ..
cmake --build . --config Release --target installIf needed, you can specify a generator by doing cmake -G "Visual Studio 14 2015 Win64" .. instead of cmake ..
Note: On Windows, you'll need to have a Lua static library available that can be found by cmake (preferably built with the same compiler you're using to build lua-sass).
From the lua-sass directory, do the following:
mkdir build && cd build
cmake ..
make
make installBy default, libsass will be built and linked statically. However, the CMake option WITH_SHARED_LIBSASS can be turned on to build against an existing shared library of libsass. Note: this has only been tested on Windows so far.
The sass module provides 2 functions, which are named in accordance with
their libsass counterparts:
local css, err = sass.compile(scss, style)
Parameters:
scss: A string of SCSS input text.style: The output style. Either"nested"or"compressed"(optional; defaults to"nested").
Returns:
Either a string of CSS on success, or nil and an error message on failure.
local css, err = sass.compile_file(filename, style)
Parameters:
filename: An SCSS file to read input from.- As above.
Returns:
As above.
Compiling a string and using the assert idiom for error handling:
local sass = require "sass"
local css = assert(sass.compile "$x: red; div {color: $x}")
print(css)Compiling a file and using explicit error handling:
local sass = require "sass"
local css, err = sass.compile_file("file.scss", "nested")
if css then
print(css)
else
io.stderr:write("Error: ", err, "\n")
end