npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vinsea/console-webpack-plugin

v1.1.1

Published

print log after webpack is done

Downloads

1

Readme

console-webpack-plugin

作用:在webpack执行结束时,将指定的文本输出到控制台

用法

安装

npm i @vinsea/console-webpack-plugin -D

webpack

plugins: [
    new ConsoleWebpackPlugin([
        { text: process.env.NODE_ENV, type: 'title' },
        { text: `gateway: ${YOUR_URL_CONFIG}`, type: 'info' },
     ]))
]

vue cli3 项目

vue.config.js

const ConsoleWebpackPlugin = require('@vinsea/console-webpack-plugin')

module.exports = {
  configureWebpack: config => {
    if (process.env.NODE_ENV !== 'production') {
      // 要在dev环境或者prod环境输出,根据自己情况来定
      config.plugins.push(new ConsoleWebpackPlugin([ {YOUR_CONFIG} ]));
    }
  }
}

vue cli2

cli2内置FriendlyErrorsPlugin,可以直接修改webpack配置文件,不用这个插件

build/webpack.dev.conf.js

// Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
  compilationSuccessInfo: {
    messages: [
               `项目运行地址为: http://${devWebpackConfig.devServer.host}:${port} \n`,
               '当前启动的环境是: xxxxx'
               ],
    notes: [`当前网关为:xxxxx`]
  }
}))

如果用此插件:

build/webpack.dev.conf.js

const ConsoleWebpackPlugin = require('@vinsea/console-webpack-plugin')

const devWebpackConfig = merge(baseWebpackConfig, {
  // ...
})

module.exports = new Promise((resolve, reject) => {
  portfinder.basePort = process.env.PORT || config.dev.port
  portfinder.getPort((err, port) => {
    if (err) {
      reject(err)
    } else {
      // ...
      // 不用 FriendlyErrorsPlugin
      // ...
      
      devWebpackConfig.plugins.push(new ConsoleWebpackPlugin([ 这里是数据 ]))
      resolve(devWebpackConfig)
    }
  })
})

或者 build/webpack.prod.conf.js

const webpackConfig = merge(baseWebpackConfig, {
  // ...
})

webpackConfig.plugins.push(new ConsoleWebpackPlugin([ 这里是数据 ]))

module.exports = webpackConfig

参数

ConsoleWebpackPlugin构造函数需要传一个数组,数组中每一项代表每一行要输出的内容;

每一行内容的数据为一个对象object格式

| 参数 | 类型 | 是否必传 | 默认值 | 说明 | | ------ | ------ |------- |------ |------ | | text | string |是 | 无 |要展示的文本 | | type | string |否 | log |文本展示的类型,可选值:title、info、log | | color | string |否 | white|文本颜色,可选值:chalk支持的颜色 ] | | options| object |否 | {horizontalLayout: 'full'}|只有type为title时生效,配置figlet|

详情查看下方示例

示例

输出大标题

new ConsoleWebpackPlugin([
    { 
      text: 'hahahaha', 
      type: 'title' 
    },
])

大标题通过 figlet 实现,figlet的配置通过options参数设置,格式和官网一样,如:

new ConsoleWebpackPlugin([
    { 
      text: 'hahahaha', 
      type: 'title',
      options: {
          width: 80,
          whitespaceBreak: true
      }
    },
])

输出常规信息

new ConsoleWebpackPlugin([
    { text: '当前环境:测试', type: 'info' },
])

输出日志类信息

new ConsoleWebpackPlugin([
    { text: '当前环境:测试', type: 'log' },
])