nestia-webpack-server
v0.1.1
Published
A faster webpack dev middleware.
Downloads
2
Maintainers
Readme
nestia-webpack-server
An fast development middleware for use with webpack bundles and allows for serving of the files emitted from webpack. This should be used for development only.
Different from webpack-dev-middleware and webpack-dev-server:
- Only lazy mode supported.
- Different from webpack-dev-server, nestia-webpack-server supports multi-entries rather than only one entry file.
- Different from webpack-dev-middleware (in lazy mode), nestia-webpack-server re-compiles only requested entry(contains requested file) rather than the whole project.
- Different from webpack-dev-middleware (in lazy mode), nestia-webpack-server re-compiles only when dependency file(s) of requested entry(contains requested file) changed.
Getting Started
First thing's first, install the module:
npm install nestia-webpack-server --save-dev
Note: We do not recommend installing this module globally.
Requirements
webpack-dev-middleware
requires Node v6 or higher, and must be used with a
server that accepts express-style middleware.
Usage
const FastServer = require('nestia-webpack-server');
const parameter = require('./webpack.config.js');
let fastServer = new FastServer({
parameterFactory: function () {
return require('./webpack.config.js');
},
entryDir: path.resolve('./expose'),
srcDir: path.resolve('./src'),
buildDir: path.resolve('./build'),
host: '0.0.0.0',
port: '8080',
}, parameter);
fastServer.on('READY',()=>{
console.log('Server is ready');
});
Options
The middleware accepts an options
Object. The following is a property reference
for the Object.
Note: srcDir,buildDir,parameter(or parameterFactory) are required.
srcDir
Type: String
Default: undefined
Defines where source code are stored.
buildDir
Type: String
Default: undefined
Defines where compiled code are stored. It also should be the root directory of the web server.
host
Type: String
Default: undefined
The IP address or hostname passed to web server to listen.
port
Type: Number
Default: undefined
The port number passed to web server to listen.
parameterFactory
Type: Function
Default: undefined
Function used to rescan entry directory, and rebuild webpack parameter.It has higher prority when parameterFactory and parameter both setted.
entryDir
Type: Function
Default: undefined
Function used to rescan entry directory, and rebuild webpack parameter.It has higher prority when parameterFactory and parameter both setted.