webpack-dev-server
Advanced tools
Comparing version
@@ -5,26 +5,33 @@ #!/usr/bin/env node | ||
var Server = require("../lib/Server"); | ||
var webpack = require("webpack"); | ||
var argv = require("optimist") | ||
var optimist = require("optimist") | ||
.usage("webpack-dev-server " + require("../package.json").version + "\n" + | ||
"webpack-dev-server <webpack entry point>") | ||
"Usage: https://github.com/webpack/docs/wiki/webpack-detailed-usage") | ||
.string("content-page") | ||
.describe("content-page", "A html page to load") | ||
.boolean("colors").alias("colors", "c").describe("colors") | ||
.string("content-url") | ||
.describe("content-url", "A url to load") | ||
.boolean("info").describe("info").default("info", true) | ||
.string("options") | ||
.describe("options", "webpack options") | ||
.boolean("quiet").describe("quiet") | ||
.describe("port", "The port") | ||
.default("port", 8080) | ||
.string("content-page").describe("content-page", "A html page to load") | ||
.demand(1) | ||
.string("content-url").describe("content-url", "A url to load") | ||
.argv; | ||
.describe("port", "The port").default("port", 8080); | ||
require("webpack/bin/config-optimist")(optimist); | ||
var argv = optimist.argv; | ||
var options = {}; | ||
var wpOpt = require("webpack/bin/convert-argv")(optimist, argv, { outputFilename: "/bundle.js" }); | ||
options.publicPath = wpOpt.output.publicPath; | ||
options.path = wpOpt.output.path; | ||
options.filename = wpOpt.output.filename; | ||
if(argv["content-page"]) | ||
@@ -36,7 +43,11 @@ options.content = path.resolve(argv["content-page"]); | ||
if(argv.options) | ||
options.webpack = require(path.resolve(argv.options)); | ||
if(argv["colors"]) | ||
options.stats = { colors: true }; | ||
var arg = argv._[0].split("!"); | ||
arg.push(path.resolve(arg.pop())); | ||
new Server(arg.join("!"), options).listen(argv.port); | ||
if(!argv["info"]) | ||
options.noInfo = true; | ||
if(argv["quiet"]) | ||
options.quiet = true; | ||
new Server(webpack(wpOpt), options).listen(argv.port); |
@@ -0,0 +0,0 @@ var $ = require("jquery"); |
require("./jquery-1.8.1"); | ||
module.exports = jQuery; |
module.exports = require("./socket.io"); |
@@ -0,0 +0,0 @@ require("./style.less"); |
@@ -6,3 +6,3 @@ # example | ||
``` text | ||
webpack-dev-server app.js | ||
webpack-dev-server ./app.js --colors | ||
``` | ||
@@ -13,3 +13,3 @@ | ||
``` text | ||
webpack-dev-server app.js --content-page index.html | ||
webpack-dev-server ./app.js --colors --content-page index.html | ||
``` | ||
@@ -21,3 +21,3 @@ | ||
``` text | ||
webpack-dev-server app.js --options webpackOptions.js | ||
webpack-dev-server ./app.js --colors --config alternative.config.js | ||
``` | ||
@@ -28,3 +28,3 @@ | ||
``` text | ||
webpack-dev-server app.js --content-page example\index.html --options webpackOptions.js | ||
webpack-dev-server ./app.js --colors --content-page index.html --config alternative.config.js | ||
``` | ||
@@ -31,0 +31,0 @@ |
var fs = require("fs"); | ||
var path = require("path"); | ||
var EventEmitter = require("events").EventEmitter; | ||
var webpackDevMiddleware = require("webpack-dev-middleware"); | ||
@@ -9,3 +8,3 @@ var express = require("express"); | ||
function Server(entry, options) { | ||
function Server(compiler, options) { | ||
@@ -17,20 +16,12 @@ // Default options | ||
this.contentUrl = options.contentUrl; | ||
this.webpackOptions = options.webpack || { | ||
output: "bundle.js", | ||
publicPrefix: "/", | ||
debug: true, | ||
filenames: true, | ||
watch: true | ||
}; | ||
this.middlewareOptions = options.middleware || {}; | ||
this.middlewareOptions.webpack = this.webpackOptions; | ||
// Listening for events | ||
this.webpackOptions.events = this.webpackOptions.events || new EventEmitter(); | ||
this.webpackOptions.events.on("bundle-invalid", function() { | ||
var invalidPlugin = function() { | ||
if(this.io) this.io.sockets.emit("invalid"); | ||
}.bind(this)); | ||
this.webpackOptions.events.on("bundle", function(stats) { | ||
}.bind(this); | ||
compiler.plugin("compile", invalidPlugin); | ||
compiler.plugin("invalid", invalidPlugin); | ||
compiler.plugin("done", function(stats) { | ||
if(!this.io) return; | ||
this._sendStats(this.io.sockets, stats); | ||
this._sendStats(this.io.sockets, stats.toJson()); | ||
this._stats = stats; | ||
@@ -52,3 +43,3 @@ }.bind(this)); | ||
// serve webpack bundle | ||
app.use(webpackDevMiddleware(entry, this.middlewareOptions)); | ||
app.use(webpackDevMiddleware(compiler, options)); | ||
}.bind(this)); | ||
@@ -77,3 +68,3 @@ | ||
if(!this._stats) return; | ||
this._sendStats(socket, this._stats); | ||
this._sendStats(socket, this._stats.toJson()); | ||
}.bind(this)); | ||
@@ -80,0 +71,0 @@ } |
{ | ||
"name": "webpack-dev-server", | ||
"version": "0.8.2", | ||
"version": "0.9.0", | ||
"author": "Tobias Koppers @sokra", | ||
"description": "Serves a webpack app. Updates the browser on changes.", | ||
"dependencies": { | ||
"webpack-dev-middleware": "0.8.x", | ||
"webpack": "0.8.x", | ||
"express": "3.0.x", | ||
"webpack-dev-middleware": "0.9.x", | ||
"webpack": "0.9.x", | ||
"css-loader": "0.5.x", | ||
"style-loader": "0.5.x", | ||
"jade-loader": "0.5.x", | ||
"express": "3.1.x", | ||
"socket.io": "0.9.x", | ||
@@ -24,6 +27,4 @@ "optimist": "0.3.x", | ||
"scripts": { | ||
"postinstall": "node ./bin/webpack client/live.js client/live.bundle.js --colors", | ||
"postupdate": "node ./bin/webpack client/live.js client/live.bundle.js --colors" | ||
}, | ||
"license": "MIT" | ||
"prepublish": "webpack ./client/live.js client/live.bundle.js --colors --config client/webpack.config.js" | ||
} | ||
} |
@@ -0,0 +0,0 @@ # webpack-dev-server |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
755583
96.34%24
9.09%22538
101.07%0
-100%3
-25%9
50%2
Infinity%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated