baka is a dead stupid inliner / importer for sass and scss files. Meaning after you run it, you'll end up with a single flattened sass or scss file with little external depenedencies.
npm install @joneff/baka --save-devconst baka = require('@joneff/baka');
let file = '/path/to/file.scss';
// Basic usage
baka.render({ file }); // returns the result of compilation
baka.build({ file }); // writes the result of compilation to /dist
// Advance usage (for build)
const path = require('path');
baka.build({
file: file,
output: {
path: path.resolve( __dirname, 'dist/flat' ),
filename: 'flat-[name].scss'
}
});The api is modeled after sass js api with some inspiration from webpack.
render( options: BakaOptions ) : String
Synchronously compiles a file to inline its imports. If it succeeds, it returns the result as a string. It takes an options object, which must have file key set.
build( options: BakaOptions ) : void
Internally calls render and if successful, writes the result to the file system.
Controls how files are loaded and output. There are a handful of options, but not all matter all the time. Here are the most important ones:
file: string
Path to the file to compile.
output: OutputOptions
A set of options instructing baka on how and where it should output the result of compilation. Similar to webpack output configuration, but only supports path and filename.
pathis the output directory as absolute path. Defaults topath.join(process.cwd(), 'dist').filenamedetermines the name of the output file. It suports the following template strings:[file],[path],[base],[name]and[ext]and they have the same meaning as with webpack. Defaults to[name]-flat[ext].
I am not really a fan of complex regex for simple tasks, like parsing @import. The following is valid syntax:
/**/ @import "file.css"; /**/ //Yet, baka will not match it. So you could say that there are intended bugs. Speaking of which, uikit can not be flattened right now.
Sure.