A node module and cli utility to create OpenUI5 Component-preload.js and library-preload.json files.
This is a fork of the preload task from grunt-openui5 with the grunt dependency removed. It behaves the same aside from some default logging differences, and has very similar options.
The goal of this project is to be the core implementation usuable by vanilla node, a grunt plugin wrapper or a gulp plugin, similar to uglify-js and its corresponding gulp & grunt plugins.
Andvanced CLI in progress (can be used now with the -x <config_file>
option)
From NPM for programmatic use:
npm install openui5-preload --save-dev
OR
yarn add openui5-preload --dev
var preload = require("openui5_preload");
//OR ES2015
import preload from "openui5_preload";
preload({
resources: ['.'],
dest: '.',
compress: true,
verbose: false,
components: ['**'],
libraries: ['**']
});
Type: String
or Object
or Array<String|Object>
Resources/files that should be used as source for preload files.
Type | Result | Example |
---|---|---|
String | See Resource.cwd . |
'src' |
Object | See Resource.* |
{ cwd: 'webapp', prefix: 'my/app', src: '**' } |
Array | Array of `String | Object` |
Type: String
Base/root directory for finding resources.
Type: String
Default:
Directory namespace prefix that should be prepended to all found paths. This is useful if the source folder structure is not the same as the module namespace.
Example:
{ cwd: 'webapp', prefix: 'my/app' }
webapp/foo.js
will be treated as my/app/foo.js
instead of foo.js
.
Type: String
or Array<String>
Default:
[
'**/*.js',
'**/*.fragment.html',
'**/*.fragment.json',
'**/*.fragment.xml',
'**/*.view.html',
'**/*.view.json',
'**/*.view.xml',
'**/*.properties'
]
Glob pattern(s) for finding relevant resources inside cwd
. If set, the default patterns will be replaced.
Type: string
Default: json
Sets the UI5 version used for compatibility mode in the format <major>.<minor>
, or keywords json
or edge
.
NOTE: Unlike SAP's grunt-openui5 (https://github.com/SAP/grunt-openui5), the default behaviour is the legacy json mode, not the edge js mode.
Example:
When building for UI5 target version 1.38.x, use compatVersion: '1.38'
.
Type: String
Default value: .
Path to the dest folder in which the preload files should be created.
Type: boolean
Default value: true
Optional parameter to set compression/minification of the files.
- JavaScript is minified using terser and copyright comments are preserved (comments matching regular expression
/copyright|\(c\)|released under|license|\u00a9/i
) - XML is minified using pretty-data
- JSON is parsed for correctness and to remove extra whitespace
Type: boolean
Default value: false
Optional parameter to have more detailed logging.
Enable auto detection of Components. A preload file will be created for each Component.js
file.
components: true
Namespace path(s) to Component(s).
components: 'my/app',
components: [ 'my/app', 'my/component']
Map with namespace path to Component as key and object as value.
components: {
'my/app': {
src: [
'my/app/**',
'my/app/!ignore.js'
]
}
}
Type: String
/ array
of String
Default: component namespace path + /**
(e.g. my/app/**
)
Glob pattern(s) for files that should be included into the preload.
Patterns are based on all available resources (see resources).
See components. Auto mode is looking for library.js
files.
Creates dist/Component-preload.js
.
preload({
resources: {
cwd: 'webapp',
prefix: 'my/app'
},
dest: 'dist'
components: 'my/app'
});
Creates dist/my/ui/lib/library-preload.json
.
preload({
resources: 'src',
dest: 'dist'
libraries: 'my/ui/lib'
});
[Apache License 2.0](http: //www.apache.org/licenses/LICENSE-2.0) © 2015 [Ryan Murphy]