Webpack 网页包开发服务器-重新加载/重新编译不';行不通

Webpack 网页包开发服务器-重新加载/重新编译不';行不通,webpack,Webpack,我正在尝试让WDS自动重新编译并重新加载我的页面 我的网页配置如下: module.exports = { devtool: 'eval', entry: './app/js/index.js', output: { filename: './public/js/index.js' }, module: { loaders: [ { test: /\.js$/, exclude: /(node_modules)/,

我正在尝试让WDS自动重新编译并重新加载我的页面

我的网页配置如下:

module.exports = {
  devtool: 'eval',
  entry: './app/js/index.js',
  output: {
    filename: './public/js/index.js'
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /(node_modules)/,
        loader: 'babel-loader'
      },
      {
        test: /\.scss$/,
        exclude: /(node_modules)/,
        use: [
          { loader: 'style-loader' },
          { loader: 'css-loader' },
          { loader: 'sass-loader' }
        ]
      }
    ]
  },
  devServer: {
    publicPath: "./public",
    hot: true
  }
};
访问
localhost:8080
会显示
index.html
页面,但没有任何注入代码。我能做什么


我正在使用webpack 2.2.1 webpack dev server 2.3.0。

您需要在html页面中参考文件./public/js/index.js。例如,在本例中,您需要在html文件中添加

<head>
    script src="../public/js/index.js" ></script>
<head>

script src=“../public/js/index.js”>

无论如何,要回答您的问题,您需要查看您的html文件。

您需要在html页面中参考文件./public/js/index.js。例如,在本例中,您需要在html文件中添加

<head>
    script src="../public/js/index.js" ></script>
<head>

script src=“../public/js/index.js”>
无论如何,要回答您的问题,您需要查看您的html文件