Babel plugin for Metalsmith
npm install metalsmith-babel
And ensure the requisite Babel plugins are installed.
Add the metalsmith-babel
field to your metalsmith.json
.
{
"plugins": {
"metalsmith-babel": {
"presets": ["env"]
"modules": "common",
"comments": true
}
}
}
const Metalsmith = require('metalsmith');
const babel = require('metalsmith-babel');
const babelOptions = {
presets: ['env']
};
new Metalsmith('./source')
.use(babel(babelOptions))
.build((err, files) => {
if (err) {
throw err;
}
console.log('Completed.');
});
All Babel options are available except for filename
, filenameRelative
and sourceMapTarget
that will be automatically set.
ISC License © 2017 Shinnosuke Watanabe