shellscape/koa-webpack

An error occurred when i set hot true

Chryseis opened this issue · 1 comments

The Issues page for this repository is not a support forum, it is for reporting potential bugs in this module, which
composes webpack-hot-middleware and webpack-dev-middle for use with koa2.
If you have arrived here because you cannot get webpack-hot-middleware
or webpack-dev-middleware working, please review the documentation
for the respective middleware you are experiencing a problem with. If you proceed with this form, please fill out all fields, or your issue may be closed as "invalid." Please remove this header to acknowledge this message.

  • Node Version:9.8.0
  • NPM Version:5.6.0
  • koa Version:2.5.0
  • koa-wepback Version:3.0.2
 {
    devtool: "source-map",
    module: {
        rules: [
            {
                test: /\.(js|jsx)?/,
                include: [
                    path.resolve(__dirname, '../src')
                ],
                exclude: [
                    path.resolve(__dirname, '../node_modules'), path.resolve(__dirname, '../src/index.html')
                ],
                loader: ['babel-loader', 'eslint-loader']
            },
            {
                test: /.(css|less)$/,
                use: ['style-loader', 'css-loader', {loader: 'less-loader', options: { javascriptEnabled: true }}]
            },
            {
                test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
                use: [{
                    loader: 'url-loader',
                    options: {
                        limit: 10000,
                        name: 'static/img/[name][hash:7].[ext]'
                    }
                }]
            },
            {
                test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
                use: [{
                    loader: 'url-loader',
                    options: {
                        limit: 10000,
                        name: 'static/fonts/[name][hash:7].[ext]'
                    }
                }]
            }
        ]
    },
    resolve: {
        extensions: [".js", ".json", ".jsx", ".css", ".less"]
    }
}

merge(baseWebpackConfig, {
    mode: 'development',
    entry: {
        app: ['webpack-hot-middleware/client?reload=true', path.resolve(__dirname, '../src/index')],
        vendor: ['react', 'react-dom', 'dva', 'lodash']
    },
    output: {
        path: path.resolve(__dirname, 'dist'),
        publicPath: '/',
        filename: 'js/[name].js',
        chunkFilename: 'js/[name].js',
        sourceMapFilename: '[file].map'
    },
    optimization: {
        splitChunks: {
            cacheGroups: {
                default: false,
                commons: {
                    test: /react|react-dom|dva|lodash/,
                    name: "vendor",
                    chunks: "all"
                }
            }
        }
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new HtmlWebpackPlugin({
            title: 'AWM',
            favicon: path.resolve(__dirname, '../src/assets/favicon.ico'),
            filename: 'index.html',
            template: path.resolve(__dirname, '../src/index.html'),
            chunks: ['app', 'vendor']
        })
    ]
})

error:
image

koa-webpack does not inject anything into the browser. Your issue lies with either webpack-dev-middleware or webpack-hot-client. You'll have to figure out which.