Gulp plug-in to automate the compilation of Slice files to JavaScript.
npm install gulp-ice-builder --save-dev
gulp-ice-builder
calls the slice2js
compiler. You can install the latest slice2js with:
npm install slice2js --save-dev
const iceBuilder = require('gulp-ice-builder');
gulp.task("slice2js", () => {
return gulp.src('slice/*.ice')
.pipe(iceBuilder())
.pipe(gulp.dest("."));
});
The root directory of your Ice installation used for locating the Slice-to-JS compiler and Slice files of your Ice installation, you don't need to set it when using the slice2js npm package.
iceBuilder({
iceHome: "/opt/Ice-3.7.1"})
If not set, the builder will try to use the slice2js npm package.
The directory of the slice2js
executable. This setting is ignored when using the slice2js npm package (iceHome
not set).
iceBuilder({
iceHome: "c:\ice",
iceToolsPath: "c:\ice\cpp\bin\x64\Release"});
When not set <iceHome>/bin
and <iceHome>/cpp/bin
are searched for the slice2js
exectuable.
List of directories to add to Slice compiler include file search path.
iceBuilder({
include: ["."]});
Each directory in include
is passed to slice2js
as -I<dir>
. The Ice slice file
directory is automatically included from either the slice2js npm package or iceHome
(when set).
The list of extra arguments passed to the slice2js
compiler.
iceBuilder({
args: ["-DDEBUG"]});
For a full list of arguments you can pass to the slice2js
compiler refer to slice2js.
Create a JavaScript bundle for each js:module
, the bundle contains the JavaScript generated
code for all the Slice compilation units that belong to a given js:module
, an extra bundled
named generated.js
is generated containing all the JavaScript generated code for Slice compilation
units that doesn't belong to any js:module
.
The jsbundle
option is enabled by default when args
contains --typescript
value. It can
be manually enabled and disabled by setting this property to true
or false
respectively.
The bundle creation uses Rollup module bundler and it requires that your Slice definitions use the es6 JavaScript module mapping introduced with Ice 3.7.
iceBuilder({
args: ["--typescript"],
jsbundle: false});
The output format use by Rollup generated bundled, it correspond to Rollup --format
option. The accepted
values are amd
, cjs
, es
, iife
and umd
. The default value is es
.
iceBuilder({
args: ["--typescript"],
jsbundleFormat: "cjs"});
Enable or disable the generation of source map files for the generated JavaScript bundle. The default is to
generate a source map for each generated bundled, it can be disabled by setting this option to false
.
iceBuilder({
args: ["--typescript"],
jsbundleSourcemap: false});
Create a bundle containing the TypeScript declarations for each js:module
. An extra
bundle named generated.d.ts
is generated containing the TypeScript generated declarations
for Slice compilation units that do not belong to any js:module
.
iceBuilder({
args: ["--typescript"],
tsbundle: false});
The tsbundle
option is enabled by default when args
contains --typescript
value. It can
be manually enabled and disabled by setting this property to true
or false
respectively.