Once the SPB
cli is installed you can use the cli.
spb [options] [command]
Options:
-V, --version
output the version number
-c, --config
path to config json file (default: “config.spb.json”)
-o, --out
where the compiles files should be compiled to (overwrites configurations from the config file)
--files
files that should be compiled (overwrites configurations from the config file). All files can also be defined with wildcardmatching for example ./views/*.pug
--verbose
enable verbose logging
-h, --help
display help for command
Commands:
init
generate the config file using the init-wizard.
build
build once (is default)
$ spb --config examples/hello-world/config.spb.json -o dist --files test.twig ...
watch
watch and automatically build when input files change
$ spb watch --config examples/hello-world/config.spb.json
dev-server
starts the dev server
$ spb dev-server --config examples/hello-world/config.spb.json
The dev server starts a server and loads all compiled files temporarily instead of building and saving them.
When opening a html file the devserver adds a script to it to automatically reload the page when changes occure to the code.
You can use a configuration file with the flag -c
or --config
. All options declared in the config file will be overwritten by options from the cli:
spb public -c config.spb.json
if the config file has a declaration for output it will be overwritten with public
in this case.
spb public ./src/styles.css ./views/*.pug -c config.spb.json
if the config file has a declaration for files it will be overwritten with ./src/styles.css
and all ./views/*.pug
files in this case.
You can also use this projects JSON schema to ensure integrity but it is not necessary.
For example when the configuration file (for example named config.spb.json
) is in the root directory and spb
is installed locally:
{
"$schema": "node_modules/@puresamari/spb/lib/config.schema.json",
"files": [
"./src/example.pug",
"./views/*.pug",
"./src/index.twig",
"./src/images/*",
"./src/license.pdf",
"./src/main.ts",
"./src/styles.css"
],
"output": "dist/",
}
If it is necessary to add options to the builders / compilers (for example postcss plugins), you can add it to the compilers
part of the config file. Like in this example:
{
"$schema": "node_modules/@puresamari/spb/lib/config.schema.json",
...
"compilers": {
"postcss": {
"plugins": [
...
"precss", // or other
...
]
}
}
}
It is possible to run a script after a build was completed. NOTE this script will not be executed when running a dev-server
.
{
"$schema": "node_modules/@puresamari/spb/lib/config.schema.json",
...
"postBuild": "npm run deploy" // For example
}
Using this config file you can then build your project like this: $ spb -c config.spb.json
Created by Simon Rothert