1.8.6 ā€¢ Published 13 days ago

unplugin-turbo-console v1.8.6

Weekly downloads
-
License
MIT
Repository
github
Last release
13 days ago

šŸŽ„ Screen Recording

šŸ”„ Features

  • Support printing the file name, line number and variable name.

  • Support insert custom prefix and suffix.

  • Support highlight the console output based on different file types. (such as js(x), ts(x), vue, svelte, astro)

  • Support jump to the editor source code from the console output with one click.

šŸ“¦ Install

# npm
npm install -D unplugin-turbo-console
# yarn
yarn add -D unplugin-turbo-console
# pnpm
pnpm i -D unplugin-turbo-console

šŸ¦„ Usage

!TIP You can view all project examples here.

// vite.config.ts
import { defineConfig } from 'vite'
import TurboConsole from 'unplugin-turbo-console/vite'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    TurboConsole({
      /* options here */
    })
  ],
})

// nuxt.config.ts
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  modules: [
    'unplugin-turbo-console/nuxt'
  ],
  turboConsole: {
    /* options here */
  }
})

// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require('unplugin-turbo-console/webpack')({ /* options */ }),
  ],
}

// vue.config.js
const { defineConfig } = require('@vue/cli-service')

module.exports = defineConfig({
  transpileDependencies: true,
  parallel: false,
  configureWebpack: {
    plugins: [
      require('unplugin-turbo-console/webpack')({
        /* options here */
      })
    ]
  }
})

āš ļø Please add TurboConsole plugin before Sveltekit plugin

import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import TurboConsole from 'unplugin-turbo-console/vite'

export default defineConfig({
	plugins: [
		TurboConsole(),
		sveltekit()
	]
});

// astro.config.mjs
import { defineConfig } from 'astro/config'
import TurboConsole from 'unplugin-turbo-console/astro'

// https://astro.build/config
export default defineConfig({
  integrations: [
    TurboConsole()
  ]
})

// next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
  webpack(config) {
    config.plugins.push(
      require('unplugin-turbo-console/webpack')()
    )

    return config
  }
}

module.exports = nextConfig

// farm.config.ts
import { defineConfig } from '@farmfe/core';
import vue from '@vitejs/plugin-vue';
import TurboConsole from 'unplugin-turbo-console/farm'

export default defineConfig({
  vitePlugins: [
    vue(),
  ],
  plugins: [
    TurboConsole()
  ]
});

// rspack.config.js
const rspack = require('@rspack/core')
const { VueLoaderPlugin } = require('vue-loader')
/** @type {import('@rspack/cli').Configuration} */

const config = {

  plugins: [
    new VueLoaderPlugin(),
    new rspack.HtmlRspackPlugin({
      template: './index.html'
    }),
    require('unplugin-turbo-console/rspack')(),
  ],

}
module.exports = config

Options

export interface Options {
  /**
   * Add a string prefix to the console log.
   *
   * @defaultValue ''
   */
  prefix?: string
  /**
   * Add a string suffix to the console log.
   *
   * @defaultValue ''
   */
  suffix?: string
  /**
   * Whether to disable the launch editor feature.
   *
   * @defaultValue false
   */
  disableLaunchEditor?: boolean
  /**
   * Whether to disable the highlight output feature.
   *
   * @defaultValue false
   */
  disableHighlight?: boolean
  /**
   * The specific service port of launch editor server.
   *
   * @defaultValue 3070
   */
  port?: number
}

Refer all options.

Disable plugin by comments

From v1.5.0, you can use code comments to make the plugin ignore specific console statements.

  • One line disable
// turbo-console-disable-next-line
console.log('foo')
console.log('bar') // turbo-console-disable-line
  • Entire file disable
/* turbo-console-disable (On top of file) */  
console.log('foo')
console.log('bar')

Troubleshooting

Jump to editor does't work

If you get errors like this:

Could not open xxxx in the editor.

The editor process exited with an error: spawn code ENOENT.

Please make sure the code command is installed. Check more details here.

ā¤ļø Credits

Inspired by

babel-plugin-enhance-log

turbo-console-log

vite-plugin-console-line

1.8.6-beta.2

13 days ago

1.8.6-beta.1

13 days ago

1.8.6

13 days ago

1.8.5-beta.2

14 days ago

1.8.5-beta.1

14 days ago

1.8.5

14 days ago

1.8.4

15 days ago

1.8.2

18 days ago

1.8.2-beta.1

18 days ago

1.8.3-beta.1

18 days ago

1.8.3

18 days ago

1.8.1

18 days ago

1.8.0

19 days ago

1.8.0-beta.1

19 days ago

1.7.0-beta.1

27 days ago

1.7.0-beta.2

26 days ago

1.7.3

26 days ago

1.7.1

26 days ago

1.7.0

26 days ago

1.7.4

25 days ago

1.6.1

1 month ago

1.6.0

1 month ago

1.5.1

1 month ago

1.5.1-beta.0

1 month ago

1.5.0

2 months ago

1.4.1

2 months ago

1.4.0

3 months ago

1.3.0

3 months ago

1.2.1

3 months ago

1.2.0

3 months ago

1.1.4

3 months ago

1.1.3-beta.0

3 months ago

1.1.2

4 months ago

1.1.2-beta.1

4 months ago

1.1.2-beta.0

4 months ago

1.1.1

4 months ago

1.1.1-beta.0

4 months ago

1.1.1-beta.1

4 months ago

1.1.0

4 months ago

1.0.10-beta.0

4 months ago

1.0.9

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.6-beta.1

5 months ago

1.0.6-beta.0

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago

0.1.1-beta.6

5 months ago

0.1.1-beta.5

5 months ago

0.1.1-beta.4

5 months ago

0.1.1-beta.3

5 months ago

0.1.1-beta.2

5 months ago

0.1.1-beta.1

5 months ago

0.1.1-beta.0

5 months ago