webpack-dashboard README

The project's README from github.com/FormidableLabs/webpack-dashboard. As one markdown file: README.md.

Webpack Dashboard — Formidable, We build the modern web

npm version Actions Status Coverage Status Maintenance Status

A CLI dashboard for your webpack dev server

What's this all about?

When using webpack, especially for a dev server, you are probably used to seeing something like this:

https://i.imgur.com/p1uAqkD.png

That's cool, but it's mostly noise and scrolly and not super helpful. This plugin changes that. Now when you run your dev server, you basically work at NASA:

https://i.imgur.com/qL6dXJd.png

Install

$ npm install --save-dev webpack-dashboard
# ... or ...
$ yarn add --dev webpack-dashboard

ℹ️ Note: You can alternatively globally install the dashboard (e.g. npm install -g webpack-dashboard) for use with any project and everything should work the same.

Use

webpack-dashboard@^3.0.0 requires Node 8 or above. Previous versions support down to Node 6.

First, import the plugin and add it to your webpack config:

// Import the plugin:
const DashboardPlugin = require("webpack-dashboard/plugin");

// Add it to your webpack configuration plugins.
module.exports = {
  // ...
  plugins: [new DashboardPlugin()];
  // ...
};

Then, modify your dev server start script previously looked like:

"scripts": {
    "dev": "node index.js", # OR
    "dev": "webpack-dev-server", # OR
    "dev": "webpack",
}

You would change that to:

"scripts": {
    "dev": "webpack-dashboard -- node index.js", # OR
    "dev": "webpack-dashboard -- webpack-dev-server", # OR
    "dev": "webpack-dashboard -- webpack",
}

Now you can just run your start script like normal, except now, you are awesome. Not that you weren't before. I'm just saying. More so.

Customizations

More configuration customization examples can be found in our getting started guide.

For example, if you want to use a custom port of webpack-dashboard to communicate between its plugin and CLI tool, you would first set the number in the options object in webpack configuration:

plugins: [new DashboardPlugin({ port: 3001 })];

Then, you would pass it along to the CLI to match:

$ webpack-dashboard --port 3001 -- webpack

⚠️ Warning: When choosing a custom port, you need to find one that is not already in use. You should not choose one that is being used by webpack-dev-server / devServer or any other process. Instead, pick one that is only for webpack-dashboard and pair that up in the plugin configuration and CLI port flag.

Run it

Finally, start your server using whatever command you have set up. Either you have npm run dev or npm start pointed at node devServer.js or something along those lines.

Then, sit back and pretend you're an astronaut.

Supported Operating Systems and Terminals

macOS → Webpack Dashboard works in Terminal, iTerm 2, and Hyper. For mouse events, like scrolling, in Terminal you will need to ensure View → Enable Mouse Reporting is enabled. This is supported in macOS El Capitan, Sierra, and High Sierra. In iTerm 2, to select full rows of text hold the ⌥ Opt key. To select a block of text hold the ⌥ Opt + ⌘ Cmd key combination.

Windows 10 → Webpack Dashboard works in Command Prompt, PowerShell, and Linux Subsystem for Windows. Mouse events are not supported at this time, as discussed further in the documentation of the underlying terminal library we use Blessed. The main log can be scrolled using the ↑, ↓, Page Up, and Page Down keys.

Linux → Webpack Dashboard has been verified in the built-in terminal app for Debian-based Linux distributions such as Ubuntu or Mint. Mouse events and scrolling are supported automatically. To highlight or select lines hold the ⇧ Shift key.

API

webpack-dashboard (CLI)

Options
Arguments

[command] - The command you want to run, i.e. webpack-dashboard -- node index.js

Webpack plugin

Options

Note: you can also just pass a function in as an argument, which then becomes the handler, i.e. new DashboardPlugin(dashboard.setData)

Local Development

We've standardized our local development process for webpack-dashboard on using yarn. We recommend using yarn 1.10.x+, as these versions include the integrity checksum. The checksum helps to verify the integrity of an installed package before its code is executed. 🚀

To run this repo locally against our provided examples, take the usual steps.

yarn
yarn dev

We re-use a small handful of the fixtures from inspectpack so that you can work locally on the dashboard while simulating common node_modules dependency issues you might face in the wild. These live in /examples.

To change the example you're working against, simply alter the EXAMPLE env variable in the dev script in package.json to match the scenario you want to run in /examples. For example, if you want to run the tree-shaking example, change the dev script from this:

$ cross-env EXAMPLE=duplicates-esm \
  node bin/webpack-dashboard.js -- \
  webpack-cli --config examples/config/webpack.config.js --watch

to this:

$ cross-env EXAMPLE=tree-shaking WEBPACK_MODE=production \
  node bin/webpack-dashboard.js -- \
  webpack-cli --config examples/config/webpack.config.js --watch

Then just run yarn dev to get up and running. PRs are very much appreciated!

Contributing

Please see our contributing guide.

Credits

Module output deeply inspired by: https://github.com/robertknight/webpack-bundle-size-analyzer

Error output deeply inspired by: https://github.com/facebookincubator/create-react-app

Maintenance Status

Active: Formidable is actively working on this project, and we expect to continue for work for the foreseeable future. Bug reports, feature requests and pull requests are welcome.

webpack-dashboard (FormidableLabs/webpack-dashboard)

Searching Database…

这是什么?一个给 webpack 开发服务器用的 CLI 仪表盘:不用再面对满屏滚动的构建输出,你能在终端里看到一个整洁的仪表盘,构建状态、报错和日志一目了然。
它是 webpack 插件、CLI 工具,还是两者都是?两者都有,是一套工具的两个部分。你要把它的 DashboardPlugin 加到 webpack 配置里,而仪表盘本身则是一个单独的 CLI 命令,在终端里显示。
怎么把它跑起来?先安装(像 'npm install -g webpack-dashboard' 这样全局安装对任何项目都管用),把插件加到 webpack 配置里,然后把启动脚本改成通过它运行:'webpack-dashboard -- node devServer.js'。
我需要用比较新的 Node 版本吗?需要 —— webpack-dashboard@^3.0.0 要求 Node 8 或更高版本;更早的版本最低支持到 Node 6。
要让插件和 CLI 互相通信,我需要配置什么吗?默认不用 —— 它们会自动配对。你可以在插件选项里设置一个自定义端口,再用 -p 传给 CLI,但这个端口必须是没被其他程序占用的,包括 webpack-dev-server。
不管我用什么操作系统,它在我的终端里都能用吗?可以:它已在 macOS(Terminal、iTerm 2、Hyper)、Windows 10(命令提示符、PowerShell、适用于 Linux 的 Windows 子系统)以及 Ubuntu 等 Debian 系 Linux 上验证过。鼠标事件在 Windows 上不支持,在 macOS Terminal 里需要开启鼠标报告(Mouse Reporting);Linux 会自动处理。
我能调整仪表盘的外观,或者过滤它显示的内容吗?可以。CLI 选项包括 -c/--color 用于自定义 ANSI 颜色,-m/--minimal 用于极简模式,-a/--include-assets 可以让显示只列出名称匹配某个字符串前缀的资源。
这个项目还在积极维护吗?是的 —— 它的维护状态标记为活跃(Active):Formidable 在可预见的未来会持续开发,欢迎提交 bug 报告、功能请求和 pull request。
What are similar projects?volta, nodemon, edit, svgr, hotel, inspector, yoinks, vue-cli
Size
2.1 MB
Stars
14K
Age
10y
Commits · 90 Days