从本地网络访问Webpack Dev Server?(在移动设备上实现热重新加载)

Vla*_*nov 6 javascript reactjs webpack

我想从本地网络上的设备测试React网站.它适用于其他PC,但不适用于我的手机.

你们有什么想法会导致这个吗?这是我的配置文件的外观:

const webpack = require('webpack');
const path = require('path');

module.exports = {

    entry: {
        mainFeedPage: [
            'webpack/hot/only-dev-server',
            './src/mainFeedPage.js'
        ],
        venues: [
            'webpack/hot/only-dev-server',
            './src/venues.js'
        ],  
        artists: [
            'webpack/hot/only-dev-server',
            './src/artists.js'
        ]  
    },
    output: {
        path: path.resolve(__dirname, 'public'),
        filename: 'js/[name].js',
        publicPath: '/public/'
    },
    devServer: {
        inline:true,
        port: 4000,
        hot: true,
        colors: true,
        progress: true,
        host: '0.0.0.0'

    },
    module: {
        loaders: [
            {
                test: /\.jsx?$/,
                exclude: /node_modules/,
                loaders: [
                    'react-hot', 
                    'babel?presets[]=react,presets[]=es2015'
                ] 
            }
        ]
    },

    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new webpack.NoErrorsPlugin(),
        new webpack.optimize.CommonsChunkPlugin({

            // Export bundles for each entry and one for code they share
            name: "shared",
            filename: "js/shared.js",
            chunks: ["mainFeedPage", "venues"]
        })
    ],

    resolve: {
        modulesDirectories: ['node_modules', 'src', 'components', 'stores'],
        extensions: ['', '.js', '.scss'],
        root: [path.join(__dirname, './src')],
    }
};
Run Code Online (Sandbox Code Playgroud)

更新试过这个,但无法让它工作:https://github.com/gaearon/react-hot-loader/issues/107#issuecomment-85712166

Vla*_*nov 0

克里斯蒂安的例子解决了我的问题。如果您想使用捆绑包,则必须自定义 webpack.config 文件。这个问题本来可以通过谷歌搜索来解决,但我花了很多时间来理解 Node 和 Express 是如何工作的......