",
31 | "license": "MIT",
32 | "bugs": {
33 | "url": "https://github.com/ericclemmons/webpack-hot-server-example/issues"
34 | },
35 | "homepage": "https://github.com/ericclemmons/webpack-hot-server-example#readme"
36 | }
37 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Eric Clemmons
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | var NpmInstallPlugin = require("npm-install-webpack-plugin");
2 | var StartServerPlugin = require("start-server-webpack-plugin");
3 | var webpack = require("webpack");
4 |
5 | module.exports = {
6 | devtool: "inline-sourcemap",
7 |
8 | entry: {
9 | server: [
10 | "webpack/hot/poll?1000",
11 | "./src/server.js",
12 | ],
13 | },
14 |
15 | externals: [
16 | // Every non-relative module is external
17 | /^[a-z\-0-9]+$/,
18 | ],
19 |
20 | module: {
21 | loaders: [
22 | {
23 | loader: "babel-loader",
24 | query: { cacheDirectory: true },
25 | test: /\.js$/,
26 | },
27 | ],
28 | },
29 |
30 | node: {
31 | __filename: true,
32 | __dirname: true,
33 | },
34 |
35 | output: {
36 | chunkFilename: "[id].[hash:5]-[chunkhash:7].js",
37 | devtoolModuleFilenameTemplate: "[absolute-resource-path]",
38 | filename: "[name].js",
39 | libraryTarget: "commonjs2",
40 | path: "./build/server",
41 | },
42 |
43 | plugins: [
44 | new StartServerPlugin(),
45 | new webpack.HotModuleReplacementPlugin(),
46 | new webpack.NamedModulesPlugin(),
47 | new webpack.NoEmitOnErrorsPlugin(),
48 | ],
49 |
50 | target: "async-node",
51 | };
52 |
--------------------------------------------------------------------------------
/src/middleware/view.js:
--------------------------------------------------------------------------------
1 | import express from "express";
2 |
3 | export default express.Router()
4 | .get("/", (req, res) => {
5 | res.send(`
6 |
7 |
8 |
9 |
10 |
11 |
15 | Webpack Hot Server Example
16 |
17 |
18 |
19 | Waiting for /api…
20 |
21 |
22 |
45 |
46 |
47 | `);
48 | })
49 | ;
50 |
--------------------------------------------------------------------------------