webpack-hot-server

A short-hand to establish a web server for hot reloading.

MIT 22 个版本
安装
npm install webpack-hot-server
yarn add webpack-hot-server
pnpm add webpack-hot-server
bun add webpack-hot-server
README

webpack-hot-server

A short-hand to establish a web server for hot reloading.

Install

$ npm install --save-dev webpack-hot-middleware webpack-hot-server

Usage

First, setup webpack-hot-middleware in your webpack config, i.e. add to entry, push the plugin.

devServer.js

You are recommended to use html-webpack-plugin to generate custom HTML output, or this module will use default index.html.

const webpack = require('wenpack')
const webpackHotServer = require('webpack-hot-server')
const webpackConfig = require('./webpack.config')

const app = webpackHotServer({
  webpack,
  config: webpackConfig,
  hot: true, // use HMR
  customIndex: true // set when your are using `html-webpack-plugin`,
  // customIndex: '/directory/to/index.html',
  // filename: 'awkward.html',
  wrap(app) {
    app.use() // ... apply your logic or middleware
  },
  compiler: {} // webpack-dev-middleware compiler options
})

app.listen(port, () => {
	console.log(`Webpack Hot Server is running at http://lcoalhost:${port}`)
})

Using with React

To enable hot reloading for React components, install babel-preset-react-hmre and put the following code in your .babelrc file:

{
	"env": {
	    "development": {
	    	"presets": ["react-hmre"]
	    }
	}
}

Then run NODE_ENV=development node devServer.js

Using with Vue

It has seamless integration with vue-loader, no additional setup if you use that.

License

MIT © EGOIST

版本列表
0.6.1 2016-10-19
0.6.0 2016-10-04
0.5.1 2016-07-30
0.5.0 2016-07-29
0.4.3 2016-05-06
0.4.2 2016-05-06
0.4.1 2016-05-06
0.4.0 2016-05-06
0.3.6 2016-04-22
0.3.5 2016-04-22
0.3.4 2016-04-22
0.3.3 2016-04-21
0.3.2 2016-04-21
0.3.1 2016-04-21
0.3.0 2016-03-28
0.2.2 2016-01-11
0.2.1 2016-01-11
0.2.0 2016-01-11
0.1.2 2016-01-11
0.1.1 2016-01-05
0.1.0 2016-01-05
0.0.1 2016-01-04