Created
November 16, 2021 15:03
-
-
Save dac09/a3748b14fd0e4ac215e084fd8ff1133c to your computer and use it in GitHub Desktop.
Revisions
-
dac09 created this gist
Nov 16, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ const template = require('@babel/template').default module.exports = { plugins: [ [ function debugPlugin({ types }) { return { name: 'debug-plugin', visitor: { Program(p, options) { const buildLogger = template(` console.log('Dannys babel plugin says hello', FILE_NAME) `) const ast = buildLogger({ FILE_NAME: types.stringLiteral(options.filename), }) console.log('Transforming:', options.filename) console.log('-'.repeat(20)) p.node.body.unshift(ast) }, }, } }, undefined, 'debug-plugin-danny-logger', ], ], }