A Metalsmith plugin for transpiling TypeScript files.
yarn add -D metalsmith-ts
const metalsmith = require('metalsmith');
const markdown = require('@metalsmith/markdown');
const layouts = require('@metalsmith/layouts');
const typescript = require('metalsmith-ts');
metalsmith(__dirname)
.metadata({
sitename: 'My Site',
})
.source('src')
.destination('build')
.use(markdown())
.use(
typescript({
outputDir: 'js/',
})
)
.use(
layouts({
suppressNoFilesError: true,
})
)
.build((err) => {
if (err) throw err;
});
The directory (relative to destination) where files will end up.
Object passed to TypeScript's transpileModule()
function. Click here for available options.
- Only files ending in
.ts
will be processed. - Files outside the source directory are ignored.