Webpack-dashboard 简单使用
npm install webpack-dashboard --save-dev
webpack config
// Import the plugin:
var DashboardPlugin = require('webpack-dashboard/plugin');
// If you aren't using express, add it to your webpack configs plugins section:
plugins: [
new DashboardPlugin()
]
// If you are using an express based dev server, add it with compiler.apply
compiler.apply(new DashboardPlugin());
// if using a custom port,
plugins: [
new DashboardPlugin({ port: 3001 })
]
// In the latest version, you can either run your app, and run webpack-dashboard independently (by installing with npm install webpack-dashboard -g) or run webpack-dashboard from your package.json. So if your dev server start script previously looked like:
"scripts": {
"dev": "node index.js"
}
// change that to :
"scripts": {
"dev": "webpack-dashboard -- node index.js"
}
// 目录结构
├── package.json
├── public
│ ├── index.html
│ └── style.css
├── server.js
├── src
│ └── index.js
└── webpack.config.js
// package.json
{
"name": "webpack-dashboard-demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node server.js",
"prebuild": "rm -rf dist && mkdir dist && cp public/* dist/",
"build": "webpack",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel-core": "^6.13.2",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.13.2",
"babel-preset-react": "^6.11.1",
"react": "^15.3.0",
"react-dom": "^15.3.0",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1"
},
"devDependencies": {
"webpack-dashboard": "0.0.1"
}
}
//server.js
var path = require('path');
var express = require('express');
var webpack = require('webpack');
var config = require('./webpack.config');
var Dashboard = require("webpack-dashboard");
var DashboardPlugin = require("webpack-dashboard/plugin");
var app = express();
var compiler = webpack(config);
var dashboard = new Dashboard();
compiler.apply(new DashboardPlugin(dashboard.setData));
app.use(express.static('public'));
app.use(require('webpack-dev-middleware')(compiler, {
quiet: true
}));
app.listen(8080, "0.0.0.0", function(err) {
if (err) {
console.log(err);
return;
}
console.log('Listening at http://0.0.0.0:8080');
});
// webpack.config.js
module.exports = {
devtool: "inline-source-map",
entry: __dirname + "/src/index.js",
output: {
filename: "bundle.js",
path: __dirname + "/dist/"
},
devServer: {
contentBase: "public/"
},
module: {
loaders: [
{
test: /\.js$/,
include: __dirname + "/src/",
loader: "babel-loader"
}
]
}
}
// index.js
import React from 'react';
import reactDOM from 'react-dom';
reactDOM.render(
<div>
<h1>A Webpack Dashboard dalong demo?!</h1>
<p>Thanks, <a href="https://formidable.com/blog/2016/08/15/introducing-webpack-dashboard/">FormidableLabs</a>!</p>
<p>(Check out the source <a href="https://github.com/FormidableLabs/webpack-dashboard">here</a>)</p>
</div>,
document.getElementById('root')
);



https://github.com/FormidableLabs/webpack-dashboard
Webpack-dashboard 简单使用的更多相关文章
- 使用webstorm+webpack构建简单入门级“HelloWorld”的应用&&引用jquery来实现alert
使用webstorm+webpack构建简单入门级"HelloWorld"的应用&&构建使用jquery来实现 1.首先你自己把webstorm安装完成. 请参考这 ...
- [Webpack] Use the Webpack Dashboard to Monitor Webpack Operations
Learn how to use the new Webpack Dashboard from Formidable Labs to display a pretty, useful output f ...
- vue.js+webpack在一个简单实例中的使用过程demo
这里主要记录vue.js+webpack在一个简单实例中的使用过程 说明:本次搭建基于Win 7平台 Node.js 安装官网提供了支持多种平台的的LTS版本下载,我们根据需要来进行下载安装.对于Wi ...
- 使用webstorm+webpack构建简单入门级“HelloWorld”的应用&&构建使用jquery来实现
使用webstorm+webpack构建简单入门级“HelloWorld”的应用&&构建使用jquery来实现 1.首先你自己把webstorm安装完成. 请参考这篇文章进行安装和破解 ...
- vue+node+es6+webpack创建简单vue的demo
闲聊: 小颖之前一直说是写一篇用vue做的简单demo的文章,然而小颖总是给自己找借口,说没时间,这一没时间一下就推到现在了,今天抽时间把这个简单的demo整理下,给大家分享出来,希望对大家也有所帮助 ...
- webpack的简单使用
今天简单的说一下webpack的使用. 打开cmd(也可以用别的看个人爱好) 打开你要创建项目的文件夹: webpack安装: 1.全局安装webpack:$npm install webpack - ...
- webpack的简单配置
本人刚开始也不会写webpack配置,刚开始在网上搜索了了一些,看的也是刚刚理解,所以准备自己写下来,已作纪念和贡献给像我一样不会配置的“童鞋”们! 1.创建webpack配置文件 在项目文件下创建一 ...
- webpack 4 简单介绍
webpack是什么? webpack是一个现代JavaScript应用程序的静态模块打包器(module bundler). 为什么要使用webpack呢? 随着web技术的发展,前端开发不再仅仅是 ...
- webpack最简单的入门教程里bundle.js之运行单步调试的原理解析
读这篇文章的朋友,请确保对webpack有最基础的认识. 您可以阅读我前一篇文章:Webpack 10分钟入门 来在本地运行一个Webpack的hello world项目.https://www.to ...
- Node 使用webpack编写简单的前端应用
编写目的 1. 使用 Node 依赖webpack.jQuery编写简单的前端应用. 操作步骤 (1)新建一个目录 $ mkdir simple-app-demo $ cd simple-app-de ...
随机推荐
- Python 之 matplotlib (十六)Animation动画【转】
本文转载自:https://blog.csdn.net/wangsiji_buaa/article/details/80057875 代码: import matplotlib.pyplot as ...
- Linux(CentOS)中常用软件安装,使用及异常——XManager, 中文支持,JDK
XManager图形化界面远程连接 采用Xshell的方式可以不用在CentOS系统中配置即可以相连,主要原理就是SSH连接的方式,但是XManager图形化界面远程连接是需要修改CentOS系统的. ...
- 定制swagger的UI
https://github.com/RSuter/NSwag/wiki#ways-to-use-the-toolchain Customizations Swagger generation: Yo ...
- lua笔记之userdata
1.一直使用框架里封装好的c库,想着自己一点一点的写些例子,学习下,以后需要c库,可以自己写了. 下边是一个简单的userdata的例子--数组操作. newarray.c #include &quo ...
- Search in Rotated Sorted Array, 查找反转有序序列。利用二分查找的思想。反转序列。
问题描述:一个有序序列经过反转,得到一个新的序列,查找新序列的某个元素.12345->45123. 算法思想:利用二分查找的思想,都是把要找的目标元素限制在一个小范围的有序序列中.这个题和二分查 ...
- js 技巧总结
插件解析 我们理解您需要更便捷更高效的工具记录思想,整理笔记.知识,并将其中承载的价值传播给他人,Cmd Markdown 是我们给出的答案 -- 我们为记录思想和分享知识提供更专业的工具. 您可以使 ...
- angular一些常用的方法:
angular.copy(); 用法:对Object对象的深度拷贝$scope.data = {name:'yanjinyun',age:'11'}; $scope.origData = angula ...
- 给virtualbox里linux添加共享文件夹
首先,必须要有已经在VirtualBox中安装好的Ubuntu系统,才能按照以下步骤操作,具体怎样在VirtualBox中安装Ubuntu系统百度经验里已经有很多,大家可以自己查询参照. 打开虚拟 ...
- spring3: 内置Resource实现
4.2 内置Resource实现 4.2.1 ByteArrayResource ByteArrayResource代表byte[]数组资源,对于“getInputStream”操作将返回一个By ...
- javascript简单介绍总结(一)
DOM (Document Object Model)(文档对象模型)是用于访问 HTML 元素的正式 W3C 标准.在 HTML 中,JavaScript 语句向浏览器发出的命令.语句是用分号分隔: ...