Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

babel-plugin-console-source

2.0.5 • Public • Published

Babel-plugin-console-source

Prepends file name and line numbers for each console command, based on the source files.

// app.js
class App() {
    constructor() {
        console.log('test')
    }
}
↓ ↓ ↓ ↓ ↓ ↓
class App() {
    constructor() {
        console.log('app.js (3:8)', 'test')
    }
}
 
// test.js
class Test() {
    constructor() {
        console.log('test two')
    }
}
↓ ↓ ↓ ↓ ↓ ↓
class Test() {
    constructor() {
        console.log('test.js (3:8)', 'test two')
    }
}

Usage

$ yarn add babel-plugin-console-source -D

.babelrc

{
    "plugins": [
        
        // consoleSource // No options required
        
        // You can pass in the following options
        ["console-source", {
        
            "segments": 1, // NOT REQUIRED
            // 0 = full file path (Default)
            // 1 = file name ONLY
            // 2 = file name and last segment
            
            "splitSegment": '/' // How to split the path - NOT REQUIRED
            // Default is / for Linux and OSX
            // Windows users can use "\\" here if needed
             
        }]
    ]
}

Notes

NPM Install: https://www.npmjs.com/package/babel-plugin-console-source

Keywords

none

Install

npm i babel-plugin-console-source

DownloadsWeekly Downloads

2,779

Version

2.0.5

License

MIT

Unpacked Size

4.31 kB

Total Files

6

Last publish

Collaborators

  • avatar