There's no point in using this plugin anymore.
Marko has grown a lot since I first published this gulp plugin, and now they support both run time compilation (via a require extension) and build time compilation (via a CLI). See here for more info: http://markojs.com/docs/installing/#on-the-server.
If you want to pre compile your marko files in a gulp build, you could just install marko-cli
as a dev dependency and do this (with gulp 4):
const { spawn } = require('child_process')
gulp.task('marko', () => spawn('marko', ['compile', 'hello.marko'], { stdio: 'inherit' }))
Compile Marko templates as part of your Gulp build process.
var marko = require('gulp-marko-compile');
gulp.task('marko', function() {
gulp.src('./src/*.marko')
.pipe(marko({preserveWhitespace: true}).on('error', gutil.log))
.pipe(gulp.dest('./public/'))
});
gulp-marko-compile will emit an error for cases such as invalid Marko syntax. If uncaught, the error will crash gulp.
You will need to attach a listener (i.e. .on('error')
) for the error event emitted by gulp-marko-compile:
var markoStream = marko({preserveWhitespace: true});
// Attach listener
markoStream.on('error', function(err) {});
In addition, you may utilize gulp-util's logging function:
var gutil = require('gulp-util');
// ...
var markoStream = marko({preserveWhitespace: true});
// Attach listener
markoStream.on('error', gutil.log);
Since .on(...)
returns this
, you can make you can compact it as inline code:
gulp.src('./src/*.marko')
.pipe(marko({preserveWhitespace: true}).on('error', gutil.log))
// ...
The options object supports the same options as the standard Marko compiler
Fully comply with Gulp plugin guidelines AKA write some tests
MIT License