to-build
v1.1.0
Published
Code Builder
Downloads
45
Readme
Name
to-build is a quick build generator
Description
to-build parses an index.html in development and generates a new build from it.
Installation
$> npm install to-build
Usage
Generate builds in the ./out directory with .css and .js minified
Two builds were generated in two different folders:
./out/staging
=> Contains minified files + sourcemaps
./out/production
=> Contains minified files with no sourcemaps (partially flattened folder)
$> to-build src/index.html
Options
| Options | Description | Expect | Default | |---------------|-----------------------------------------------------------------------------------------------------------------------------------------------|------------|-----------------------------------------------------------------| | --development | Only launch the server against your development folder | boolean | | | --staging | Do a build for staging | boolean | | | --production | Do a build for production | boolean | | | --all | Do a build for staging and production at once | boolean | | | --noserver | Do not run servers after builds | boolean | | | --output | The folder to hold the build | string | | | --root | Folders the engine will look up to, to resolve extracted uris including the current working directory and the node_modules folder | string[] | [, user defined, <node_modules>] | | --static | Extra Folders the engine will look up to, to resolve extracted uris if not found in the --root ones | string[] | | | --minifyCss | Whether to minify css | boolean | | | --minifyJs | Whether to minify js | boolean | | | --minifyHtml | Whether to minify html | boolean | | | --sourcemaps | Whether to generate sourcemaps | boolean | |
- Sourcemaps are not generated in production
Servers
By default, the development server runs on port 10000, staging on port 10002 and production on port 10004.
To have a quick report:
$> npx genserve scan --namespace to-build
To edit ports, locate the configuration file with:
# To get the servers configuration path
$> npx genserve path servers --namespace to-build
To stop servers
$> npx genserve stop all --namespace to-build
Examples
Generate build in a folder called "target"
$> to-build src/index.html --output target
Generate build with no source map
$> to-build src/index.html --sourcemaps false
Generate build with non-minified css
$> to-build src/index.html --minifyCss false
Generate build with non-minified html
$> to-build src/index.html --minifyHtml false
Generate build with non-minified js
$> to-build src/index.html --minifyJs false
Generate build only for production
$> to-build src/index.html --production
Generate build only for staging
$> to-build src/index.html --staging
Generate build only for development
$> to-build src/index.html --development
Changelog
current:
- Add the directive [to-build remove] to remove code from generated html files
- Fix generated html
- Fix files containing special characters in uris not processed
- Add one second pause after starting a server
- Remove duplicated log ids
- Do not start all builds automatically
- Use AnaLogger module to display logs
- Add --noserver option to prevent launching servers automatically
- Run all servers at start
- Fix generation for production assets
- Generate build for production
- Add --static options to add extras static directories
- Scan css to add more linked files to the build directory
- Start server after build
- Add missing library source-finder
- Fix build missing resource files
- Fix build generation for script module types
- Minify module type js with to-esm
- Minify HTML
- Generate css files with options from html
- Fix missing css files processing
- Run from CLI