-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
45 lines (37 loc) · 1.07 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict'
const { src, dest } = require('gulp')
const { pipeline } = require('stream')
const mjml = require('gulp-mjml')
const mjmlEngine = require('mjml')
// Register custom MJML components
const { registerComponent } = require('mjml-core')
const MjBasicComponent = require('./components/MjBasicComponent.js').default
registerComponent(MjBasicComponent)
const { registerDependencies } = require('mjml-validator')
registerDependencies({
// Tell the validator which tags are allowed as our component's parent
'mj-hero': ['mj-basic-component'],
'mj-column': ['mj-basic-component'],
// Tell the validator which tags are allowed as our component's children
'mj-basic-component': []
})
// Gulp task
function build (cb) {
return pipeline(
src('./src/index.mjml'),
// Compile MJML into HTML
mjml(mjmlEngine),
// Write HTML version
dest('./dist'),
// Error handling
err => {
if (err) {
console.error('Error!', err.message)
process.exitCode = 1
} else {
console.log('Success!')
}
}
)
}
exports.default = build