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 ...
随机推荐
- 20145120黄玄曦《网络对抗》Web基础
20145120黄玄曦<网络对抗>Web基础 回答问题 (1)什么是表单 表单在网页中主要负责数据采集功能.一个表单有三个基本组成部分: 表单标签:这里面包含了处理表单数据所用CGI程序的 ...
- 关于在asp.net添加jQuery的智能提示
如果是vs2008以后的版本,一般都会支持jQuery自动提示代码功能,不支持也没关系,很简单的操作就能支持: 1.先为vs下载一个补丁,地址为:http://code.msdn.microsoft. ...
- Spring_Bean 的作用域
beans-scope.xml <?xml version="1.0" encoding="UTF-8"?><beans xmlns=&quo ...
- 第九节课-CNN架构
2017-08-21 这次的课程比较偏向实际的运用,介绍了当前几种比较主流的CNN网络: 主要是AlexNet,GoogleNet, VGG, ResNet 需要把课后习题做了才能更好的理解.
- Mybatis plus 高级
最近项目重构 dao层使用的Mybatis plus,有必要总结下. Mybatis plus 会自动维护Mybatis 以及 MyBatis-Spring 相关依赖 所以在构建项目时候 只需要引入 ...
- Aggregate Services
https://stackoverflow.com/questions/7199097/constructor-injection-into-a-base-class-using-autofac Ca ...
- EF Code-First 学习之旅 多对多的关系
public class Student { public Student() { this.Courses = new HashSet<Course>(); } public int S ...
- Java编程时部分快捷键
alt + / 内容助理 配置:Window->properties->keys->查看alt + /的配置,然后解除当前的配置->搜索content assist->解 ...
- Git迁移 从SVN到Git
Migrating from SVN to Git 首先我们需要在Stach或者GitHub上新建一个Repository, 拿到它的URL. 接下来参照如下步骤 : At first we shou ...
- virtio guest side implementation: PCI, virtio device, virtio net and virtqueue
With the publishing of OASIS virtio specification version 1.0, virtio made another big step in becom ...