@dovenv/media - Examples β
Simple example β
This is a simple example for create/minimize/optimize media
Dovenv configuration file β
ts
import { defineConfig } from '@dovenv/core'
import {
resolvePath,
joinPath,
catchExecOutput,
} from '@dovenv/core/utils'
import core from '../../../../.dovenv/const.js'
import { mediaPlugin } from '../src/main'
const exampleFolder = resolvePath( 'examples' )
const buildFolder = resolvePath( 'build' )
const imageFolder = joinPath( exampleFolder, 'images' )
const termFolder = joinPath( exampleFolder, 'termgif' )
const ciBuildFolder = joinPath( buildFolder, 'codeimage' )
// const imagePath = joinPath( imageFolder, 'favicon.png' )
const [ dovenvError, dovenvIn ] = await catchExecOutput( 'pnpm --help' )
if ( dovenvError ) throw dovenvError
export default defineConfig(
{ const: core },
mediaPlugin( {
/** Minify config */
min : {
images : {
input : [ joinPath( imageFolder, '*' ) ],
output : joinPath( buildFolder, 'images' ),
opts : { png: true },
},
gifs : {
input : [ joinPath( termFolder, '**/*.gif' ) ],
output : joinPath( buildFolder, 'compress' ),
opts : { gif: { optimizationLevel: 3 } },
},
},
/** Generate code Images */
codeimage : {
main : {
input : joinPath( exampleFolder, 'main.ts' ),
output : ciBuildFolder,
flags : [ '--interactive' ],
},
help : {
input : dovenvIn,
output : ciBuildFolder,
flags : [ '--interactive' ],
},
},
/** Generate terminal gifs */
termgif : { test : {
configPath : joinPath( termFolder, 'test.yml' ),
output : joinPath( buildFolder, 'test-record' ),
// command : 'zsh',
// quality : 100,
} },
qr : { pigeonposse : {
input : 'https://pigeonposse.com/',
size : 'large',
} },
} ) )Run dovenv in a TS file β
ts
import { Dovenv } from '@dovenv/core'
import { hideBin } from '@dovenv/core/utils'
import config from './config'
const dovenv = new Dovenv( { config } )
const args = hideBin( process.argv )
await dovenv.run( args )Use in CLI β
bash
dovenv media [cmd]