|
4 years ago | |
---|---|---|
.. | ||
LICENSE.md | 4 years ago | |
README.md | 4 years ago | |
expansive.es | 4 years ago | |
package.json | 4 years ago |
Expansive plugin to manage Javascript files.
The exp-js plugin provides build tooling for script files. It provides the js-render service to manage the generation HTML for script files, the js-minify service to minify script files for release distributions, and the js-extract service to extract inline scripts.
pak install exp-js
Provides the following transformations:
The js transform provides configuration control for the other js services.
The js-render transform intelligently selects minified or non-minified Javascript files. By default, it selects minified scripts if a corresponding source map file with a 'min.map' extension is present. Otherwise, non-minified Javascript files with a plain .js extension will be selected.
The js-render transform also provides the renderScript
API which generates <script> elements for selected script files. The order of generated script elements will match the required order as specified by Pak dependencies.
The renderScripts API may be invoked with an argument can specify a set of patterns to select a subset of scripts for which to create script elements. This can be used to select or reject specific scripts. A second argument may specify an array of additional scripts to render.
renderScripts(['!unwanted.js'], ['extra.js'])
The js-minify transform optimizes script files by minifying to remove white-space, managle names and otherwise compress the scripts. By default, the script files use a '.js' extension, but will use a '.min.js' extension if the 'dotmin' option is enabled.
To support using Content Security Policy headers, the js-extract transform extracts inline scripts into external Javascript files. It will extract incline <script> tags and onclick attributes into a per-page external script file. If the extract attribute is set to a filename, then all the scripts will be placed in that file.
The debug
collection will be selected if the package.json pak.mode
is set to debug. Similarly for the release
collection.
debug: {
services: {
"js": {
usemap: true
}
}
}
release: {
services: {
"js": {
minify: true
}
}
}