为了账号安全,请及时绑定邮箱和手机立即绑定

使用react-hot-loader之后报错“target container is not

使用react-hot-loader之后报错“target container is not

饮歌长啸 2019-03-20 17:15:33
webpack.config.jsconst path = require('path')const webpack = require('webpack')const ExtractTextWebapckPlugin = require('extract-text-webpack-plugin') //CSS文件单独提取出来const HtmlWebpackPlugin = require('html-webpack-plugin')module.exports = {    entry: './src/index.js',    output: {        path: path.resolve(__dirname, 'dist'),//出口文件    filename: '[name].[hash:8].bundle.js'    },    module: {        rules: [{            test: /\.js|jsx$/,            exclude: /node_modules/,            use:  {                loader: 'babel-loader',                options: {              cacheDirectory: true,                    presets: ['react', 'env', 'stage-0'],              plugins: ['react-hot-loader/babel']                }            }        },{            test: /\.less$/,            use: ExtractTextWebapckPlugin.extract({          fallback: 'style-loader',          use: ['css-loader', 'less-loader']      }),      include: path.join(__dirname, 'src'),      exclude: /node_modules/     }]    },    devServer: {        contentBase: path.join(__dirname, 'src'),        publicPath: "/",        compress: true,         port: 8880,        inline: true,        hot: true    },    plugins: [        new webpack.HotModuleReplacementPlugin(),        new HtmlWebpackPlugin()    ]}index.jsimport React from 'react'import ReactDom from 'react-dom'import { hot } from 'react-hot-loader'import App from './App.jsx'const Page = hot(module)(App)console.log(document.getElementById('app'))ReactDom.render(<Page />, document.getElementById('app'))html<!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title>React</title><meta name="description" content=""><meta name="keywords" content=""><link href="" rel="stylesheet"></head><body>    <div id='app'></div>    <script src='main.5e3d29b2.bundle.js'></script></body></html>启动webpack-dev-server之后报错,页面只剩下一个script,上面的div没了,这是为什么呢?求大神解惑
查看完整描述

1 回答

?
智慧大石

TA贡献1946条经验 获得超3个赞

HtmlWebpackPlugin的配置有问题吧


查看完整回答
反对 回复 2019-04-10
  • 1 回答
  • 0 关注
  • 535 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号