2017-02-17 36 views
1

我想让WDS自动重新编译并重新加载我的页面。Webpack开发服务器 - 重新加载/重新编译不起作用

我的WebPack配置如下:

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开发服务器2.3.0。

回答

0

您需要参考该文件./public/js/index.js在HTML页面中。例如,在这种情况下,你需要在HTML文件中

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

反正添加到您问题的答案一个需要看你的HTML文件。

相关问题