kaba
A build system, specifically designed for the needs and requirements of Becklyn Studios, built on top of node-sass
and webpack.
Supported Features
- SCSS building + minification
- Babel with the kaba-babel-preset
- Typescript
- ESLint
- Stylelint
- Preact support
- Source Maps
Installation
Use npm to install kaba locally in your project:
yarn add -D kaba
# or
npm install -D kaba
Usage
Just run the executable:
npx kaba
# or
./node_modules/.bin/kaba
CLI Arguments
npx kaba --dev
name | type | description |
---|---|---|
--dev | bool | Dev mode. Equivalent to --debug --watch --lint (short: -d ) |
--debug | bool | Builds the file in debug mode (non-minified and with env development ). |
--analyze-bundles | bool | Opens the bundle analyzer. |
--analyze | bool | Analyzes and lints the code. Should be used in CI. |
--watch | bool | Starts the file watcher. |
--lint | bool | Lints all compiled files. |
--help | bool | Prints the help. |
--versions | bool | Prints the version information. (short: -V ) |
--verbose | bool | Displays all errors in the runner / config file with stack trace. |
Source Maps
Source maps are always built, either as hidden source map file or as inlined source map in --debug
.
Configuration
First, create a webpack.config.js
in the root of your project.
Load kaba and export the generate config:
const Kaba = require("kaba");
module.exports = (new Kaba())
.addEntries({
app: "assets/js/app.js"
})
.extractSharedEntry()
.getWebpackConfig();
Configuration Methods
.addEntries(mapping)
Defines the entry points for the builds. Similar to webpackConfig.entry. Can add both JavaScript and Sass entries.
kaba.addEntries({
app: "assets/js/app.js",
page: "assets/js/page.js",
test: "assets/scss/test.scss",
});
name | type | description |
---|---|---|
mapping | Object<string,string> | The mapping object defining the entry points. |
.addJavaScriptEntries(mapping)
Defines the JavaScript entry points for the webpack builds. Similar to webpackConfig.entry.
kaba.addJavaScriptEntries({
app: "assets/js/app.js",
page: "assets/js/page.js",
});
name | type | description |
---|---|---|
mapping | Object<string,string> | The mapping object defining the entry points. |
.addSassEntries(mapping)
Defines the Sass entry points. Similar to webpackConfig.entry.
kaba.addSassEntries({
test: "assets/scss/test.scss",
});
name | type | description |
---|---|---|
mapping | Object<string,string> | The mapping object defining the entry points. |
.setExternals(externals)
Adds the given imports as externals. See webpackConfig.externals for details.
kaba.setExternals({
routing: "window.Routing",
});
name | type | description |
---|---|---|
externals | Object<string,string> | The mapping for externals. |
By default no externals are registered.
.disableModuleConcatenation()
Disables the module concatenation plugin in webpack.
kaba.disableModuleConcatenation();
.setOutputPath(outputPath)
Sets the output path where all compiled files will be stored. Is relative to cwd()
. See webpackConfig.output.path (except that the path is already joined with cwd()
).
kaba.setOutputPath("build");
name | type | description |
---|---|---|
outputPath | string | The output path relative to cwd() (default: "build" ). |
.setPublicPath(publicPath)
Sets the public path for dynamic module loading. See webpackConfig.output.publicPath for details.
kaba.setPublicPath("/assets/");
name | type | description |
---|---|---|
publicPath | string | (default: "/assets/" ) |
.setBrowserList(list)
Sets the browser list for autoprefixer. See the browserlist docs for details about the format.
kaba.setBrowserList(["last 2 versions", "IE 11"]);
name | type | description |
---|---|---|
list | string[] | The browser list to use (default: ["last 2 versions", "IE 11"] ). |
.enableSassNodeModulesIncludePaths()
Normally, node_modules
libraries can just be loaded by prepending them with ~
:
@import "~mojave/reset";
Some libraries don’t use this convention however and just import directly from node_modules
. This setting can be compatible with these libraries.
kaba.enableSassNodeModulesIncludePaths();
.setJavaScriptDependenciesName(name)
Sets the filename of the JavaScript dependencies file. This file can be read and used by Assets Bundle, for example.
kaba.setJavaScriptDependenciesName("_deps.json");
name | type | description |
---|---|---|
name | string | optional The name of the file. Default is _dependencies.json . |
.enableTypeScript(compileJs)
Deprecated since version 7.3: TypeScript will be enabled by default with v8.0 and the method .enableTypeScript(compileJs)
has been removed.
Enables TypeScript support for .ts(x)
files. If the compileJs
flag is true
, both .ts
and .js
are compiled via TypeScript.
kaba.enableTypeScript(compileJs);
name | type | description |
---|---|---|
compileJs | boolean | optional Whether to compile .js files via TypeScript as well. Default is false . |
- Supported Features
- Installation
- Usage
- Configuration
- Configuration Methods
.addEntries(mapping)
.addJavaScriptEntries(mapping)
.addSassEntries(mapping)
.setExternals(externals)
.disableModuleConcatenation()
.setOutputPath(outputPath)
.setPublicPath(publicPath)
.setBrowserList(list)
.enableSassNodeModulesIncludePaths()
.setJavaScriptDependenciesName(name)
.enableTypeScript(compileJs)
- Configuration Methods