webpack-dev-server如何从根文件夹外部提供服务

时间:2019-03-25 11:52:16

标签: webpack webpack-dev-server

我已经这样配置了我的webpack:

module.exports = {

    entry: './src/index.js',
    output: {
       path: path.join(__dirname, "../Server/public/js/"),
       filename: 'bundle.js'
    },
}

"../Server/public/js/"中,我有index.html。在该html中,我引用了

<script src="./js/bundle.js" type="text/javascript"></script>

当我使用webpack编译时,它工作正常。通过此设置,如何将我的webpack-dev-server绑定(在内存中)我的js到这个"../Server/public/js/"文件夹?

到目前为止,我已经对此进行了测试并更改了路径值。但没有成功:

devServer: {
    contentBase: path.join(__dirname, "../Server/public/"),
    publicPath: path.join(__dirname, "../Server/public/"),
    filename: 'bundle.js',
    hot: true,
}

0 个答案:

没有答案
相关问题