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 ...
随机推荐
- usb gadget虚拟串口【转】
本文转载自:https://blog.csdn.net/luckywang1103/article/details/61917916 配置 配置好之后编译重新烧写到开发板,发现出现了/dev/ttyG ...
- webstorm打开带有node_modules文件夹的工程时很卡
ctrl+alt+s打开settings 在webstorm中配置这个就可以不加载出来node_modules使页面加载快
- vmware配置网卡
虚拟机网络配置 1. 启用VMWare虚拟网卡 如果没有查看到vmnet8这个网络连接,打开VMWare, 2. 设置虚拟机:选中安装好的虚拟机右键设置. 3. 设置虚拟机系统. 指令:vi /etc ...
- mysql 如果数据不存在,则插入新数据,否则更新 的实现方法
CREATE TABLE `table_test` ( `id` int(11) NOT NULL AUTO_INCREMENT, `my_key` int(11) NOT NULL DEFAULT ...
- sublime 常见问题
问题一: There Are No Packages Available For Installation 原因:官方提供的Package Control不能用.将官方的那个Package Contr ...
- hdu1695莫比乌斯反演模板题
hdu1695 求1<=i<=n&&1<=j<=m,gcd(i,j)=k的(i,j)的对数 最后的结果f(k)=Σ(1<=x<=n/k)mu[x]* ...
- redis之linux下的安装
安装 1.在/usr/local下新建redis文件夹 #mkdir redis 2.去redis.io下载redis安装包 # wget http://download.redis.io/relea ...
- 卡尔曼滤波——基本假设(1)线性系统(2)高斯分布 根据x(t) 求解x(t+1)
from:https://blog.csdn.net/u010720661/article/details/63253509 原文链接:http://www.bzarg.com/p/how-a-kal ...
- 33-THREE.JS 圆柱体
<!DOCTYPE html> <html> <head> <title></title> <script src="htt ...
- 【sparkStreaming】将DStream保存在MySQL
package SparkDemo import java.sql.{Connection, DriverManager, PreparedStatement} import org.apache.s ...