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

webpack-browser-log

v1.0.0

Published

friendly log errors on your browser

Downloads

11

Readme

webpack-broswer-log

CircleCI npm npm

Based on webpack-hot-middleware and webpack-dev-middleware friendly log errors on your browser.

中文文档在最下面

Installing

npm i webpack-browser-log --save-dev;

Usage

First, add webpack-hot-middleware/client into the entry array.Such as

entry: {
	index: ['webpack-hot-middleware/client?reload=true','./src/index.js'],
	vendor: ['vue', 'vue-router', 'vuex'],
},

Next, add the following plugins to the plugins array:

plugins : [
	new webpack.HotModuleReplacementPlugin(),
	new webpack.NoEmitOnErrorsPlugin(),
	//...
]

Now, edit your dev-client.js

// build/dev-client.js

const WebpackBrowserLog = require('webpack-browser-log'); // use webpack-browser-log
const merge = require('webpack-merge'); // use webpack-merge
const webpackDev = require('./webpack.dev'); // webpack dev config
const base = require('./webpack.base'); // webpack base config
const webpackConfig = merge(base, webpackDev); // merge base and dev

new WebpackBrowserLog(webpackConfig); // magic
$ node build/dev-client.js

Open your browser on http://localhost:3000. Let's coding

gif

Config

Because of based on webpack-dev-middleware and webpack-hot-middleware. You can read their doc directly.Enjoy yourself

new webpackBrowserLog(webpackConfig, {
	port : 3000, // default
	errorsPluginOptions: { // default
    	// https://www.npmjs.com/package/friendly-errors-webpack-plugin#options
  	},
	devMiddleware : { // default
		publicPath: webpackConfig.output.publicPath,
		quiet: true
	},
	hotMiddleware : { // default
		log: () => {}
	},
	waitUntilValid : function () { }, // default
	setup(app, express) {
		// here you can get app express
		// example
        app.use('/static', express.static('./static'));
  	},
});

Contributing

1.Fork it!

2.Create your feature branch: git checkout -b my-new-feature

3.Commit your changes: git commit -am 'Add some feature'

4.Push to the branch: git push origin my-new-feature

5.Submit a pull request :D


基于webpack-hot-middlewarewebpack-dev-middleware,可以将你的错误友好的提示在浏览器上,无需切换命令行查看错误或者看浏览器的console面板

安装

npm i webpack-browser-log --save-dev;

如何使用

首先, 把你的entry改成如下形式,每个页面入口都需要写成数组并且在最前面加webpack-hot-middleware/client?reload=true

entry: {
	index: ['webpack-hot-middleware/client?reload=true','./src/index.js'],
	vendor: ['vue', 'vue-router', 'vuex'],
},

接着, 在你的plugin里加入2个插件

plugins : [
	new webpack.HotModuleReplacementPlugin(),
	new webpack.NoEmitOnErrorsPlugin(),
	//...
]

完了以后,新建一个dev-client.js,复制如下代码

// build/dev-client.js

const WebpackBrowserLog = require('webpack-browser-log'); // 引入webpack-browser-log
const merge = require('webpack-merge'); // 引入webpack-merge
const webpackDev = require('./webpack.dev'); // 引入你webpack.dev的配置
const base = require('./webpack.base'); // 引入你webpack base的配置
const webpackConfig = merge(base,webpackDev); // 合并两配置

new WebpackBrowserLog(webpackConfig); // 默认只需要传入需要启动的webpack配置就OK了

最后,运行这个文件

$ node build/dev-client.js

打开你的浏览器,http://localhost:3000. 把你的代码故意改错试试,在浏览器上就会提示错误了

此处有gif,没看见等一会

gif

配置选项

由于使用了webpack-dev-middlewarewebpack-hot-middleware. 所以你可以直接阅读他们的文档,然后按照如下修改

new webpackBrowserLog(webpackConfig, {
	port : 3000, // 修改启动端口,默认3000
	errorsPluginOptions: { // default
		// https://www.npmjs.com/package/friendly-errors-webpack-plugin#options
	},
	devMiddleware : { // 默认配置了publicPath和quiet,你可以覆盖它
		publicPath: webpackConfig.output.publicPath,
		quiet: true
	},
	hotMiddleware : { // 默认配置了log,你可以覆盖它
		log: () => {}
	},
	waitUntilValid : function () { }, // 默认为空,这个是成功启动后的回调
	// 目前只有这4个字段是你可配置的,在下觉得已经足够了
	// new WebpackBrowserLog(webpackConfig); 最爽的就是直接这样
	setup(app, express) {
		// 注册别的中间件
		app.use('/static', express.static('./static'));
	},
});