Methods
findBinary(name, callback) → {void}
- Source:
Finds the path to a project level binary, creates a NativeProcess
for that binary, caches it for all
subsequent invocations, and provides it to the callback.
Example
import {findBinary, logError} from 'webcompiler';
// or - import {findBinary} from 'webcompiler/lib/findBinary';
// or - var findBinary = require('webcompiler').findBinary;
// or - var findBinary = require('webcompiler/lib/findBinary').findBinary;
import {logError} from 'webcompiler';
findBinary('something', (error, binary) => {
if (error) {
return logError(error);
}
binary.run(() => {
// called the `something` binary from the local project level "node_modules/.bin" directory
});
});
Parameters:
Name | Type | Description |
---|---|---|
name |
string | the binary name |
callback |
ResultOrErrorCallback | a callback function |
Returns:
- Type
- void
livereload() → {LiveReloadTrigger}
- Source:
Starts a LiveReload server and returns a function that triggers the reload.
Examples
<link rel="stylesheet" href="css/style.css">
import {livereload} from 'webcompiler';
// or - import {livereload} from 'webcompiler/lib/livereload';
// or - var livereload = require('webcompiler').livereload;
// or - var livereload = require('webcompiler/lib/livereload').livereload;
// initialize the server
const lr = livereload();
// only reload the styles
lr('css/style.css');
// refresh the whole page
lr('*');
// or simply
lr();
Returns:
the trigger function
- Type
- LiveReloadTrigger
watch(dir, type, callback)
Using the Facebook Watchman, watches the directory dir
for changes of files
with extension type
and runs callback
when a change is detected.
This watcher's only goal is performance, hence the simplicity.
Example
import {watch} from 'webcompiler';
// or - import {watch} from 'webcompiler/lib/watch';
// or - var watch = require('webcompiler').watch;
// or - var watch = require('webcompiler/lib/watch').watch;
import {join} from 'path';
watch(join(__dirname, 'src'), 'js', someFunction);
Parameters:
Name | Type | Description |
---|---|---|
dir |
string | a full system path to a directory to watch |
type |
string | a file extension |
callback |
WatchCallback | a callback function |
yaml(filename, callback)
Read the contents of a YAML file
Example
import {yaml} from 'webcompiler';
// or - import {yaml} from 'webcompiler/lib/yaml';
// or - var yaml = require('webcompiler').yaml;
// or - var yaml = require('webcompiler/lib/yaml').yaml;
import {join} from 'path';
import {logError} from 'webcompiler';
yaml(join(__dirname, 'config', 'config.yaml'), (error, data) => {
if (error) {
return logError(error);
}
// the parsed config object
});
Parameters:
Name | Type | Description |
---|---|---|
filename |
string | the full system path to a YAML file |
callback |
ObjectOrErrorCallback | a callback function |
Type Definitions
CompilerConfig
- Source:
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
compress |
boolean |
<optional> |
if true |
Base compiler configuration object
Type:
- Object
ConsoleStyleConfig
- Source:
Properties:
Name | Type | Description |
---|---|---|
ansi |
Array.<string> | ansi start and end codes |
css |
string | css styles |
A configuration object that describes a console output style.
Type:
- Object
DevServerConfig
- Source:
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
style |
string |
<optional> |
a full system path to a SASS file |
|
port |
number |
<optional> |
3000
|
a port at which to start the dev server |
react |
boolean |
<optional> |
true
|
false to disable the react hot loader plugin |
contentBase |
string |
<optional> |
CWD
|
a full system path to the server web root |
configureApplication |
ExpressApplicationCallback |
<optional> |
gives you a chance to configure the underlying Express application after the static root has been configured, but before the "catch all" route (sends the HTML layout) is defined |
DevServer configuration object
Type:
- Object
DocumentationConfig
- Source:
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
inputDir |
string |
<optional> |
"src"
|
the input application code directory |
outputDir |
string |
<optional> |
"docs"
|
the output directory for the generated documentation |
readMe |
string |
<optional> |
"README.md"
|
the documentation "homepage" (README.md file) |
template |
string |
<optional> |
"node_modules/ink-docstrap/template"
|
a full system path to a valid JSDoc3 template directory |
jsdocConfig |
string |
<optional> |
"<webcompiler root>/config/jsdoc.json"
|
a full system path to a JSDoc3 configuration file |
Documentation generator configuration object
Type:
- Object
ExpressApplicationCallback(app)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
app |
external:ExpressApplication | Express application |
JSCompilerConfig
- Source:
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
compress |
boolean |
<optional> |
if true |
|
library |
string |
<optional> |
serves the same purpose as the option with the same name in webpack |
|
libraryTarget |
string |
<optional> |
"var"
|
serves the same purpose as the option with the same name in webpack |
Base compiler configuration object
Type:
- Object
LintCallback(errorsopt)
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
errors |
Array.<LintError> |
<optional> |
a collection of error objects |
LintError
- Source:
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
file |
string | the path to a file |
|
line |
number | the offending line number |
|
column |
number | the offending column number |
|
message |
string | the error message |
|
rule |
string |
<optional> |
the name of the rule that triggered the error |
A generic linting error object
Type:
- Object
LiveReloadTrigger(fileopt)
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
file |
string |
<optional> |
"*"
|
a file to reload (same path as written in the HTML document that includes it) or |
NodeSassError
- Source:
Properties:
Name | Type | Description |
---|---|---|
file |
string | the path to a file |
line |
number | the offending line number |
column |
number | the offending column number |
message |
string | the error message |
A Node SASS error object.
Type:
- Object
ObjectOrErrorCallback(erroropt, result)
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
error |
Error |
<optional> |
an error object |
result |
Object | the resulting object |
PostCSSWarning
- Source:
Properties:
Name | Type | Description |
---|---|---|
column |
number | the offending column number |
line |
number | the offending line number |
plugin |
string | the name of the plugin that triggered the warning |
text |
string | the warning message |
node |
Object | the offending node description |
A PostCSS warning object.
Type:
- Object
ProgramData
- Source:
Properties:
Name | Type | Description |
---|---|---|
code |
string | program code |
map |
string | source map json string |
Processed application code with source maps
Type:
- Object
ProgramDataCallback(data)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
data |
ProgramData | the program data |
ResultOrErrorCallback(erroropt, result)
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
error |
Error |
<optional> |
an error object |
result |
* | the resulting value |
SASSCompilerConfig
- Source:
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
compress |
boolean |
<optional> |
if true |
|
includePaths |
Array.<string> |
<optional> |
[]
|
add additional include paths (by default includes
|
importOnce |
Object |
<optional> |
{index: true, css: false, bower: false}
|
import once plugin options |
Base compiler configuration object
Type:
- Object
StringOrErrorCallback(erroropt, result)
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
error |
Error |
<optional> |
an error object |
result |
string | the resulting string |
WatchCallback(response)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
response |
WatchmanResponse | a watchman response object |
WatchmanFile
- Source:
Properties:
Name | Type | Description |
---|---|---|
name |
string | the relative path to a file |
size |
number | file size in bytes |
exists |
boolean | true if the file exists |
type |
string | e.g. "f" |
Describes a file a change in which was caught.
Type:
- Object
WatchmanResponse
- Source:
Properties:
Name | Type | Description |
---|---|---|
root |
string | the path to the directory being watched |
subscription |
string | random subscription name |
files |
Array.<WatchmanFile> | an array of file descriptions |
A watchman response object.
Type:
- Object