[英]Accessing Webpack Dev Server from local network? (React Hot Reloading on mobile)
我想從本地網絡上的設備測試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')],
}
};
更新試過這個,但無法讓它工作: https : //github.com/gaearon/react-hot-loader/issues/107#issuecomment-85712166
這不是一個直接的解決方案,但我有一個基於Dan Abramov提供的React Transform樣板的項目,它可以在移動Android設備上完美運行。 尚未在iOS上測試過。 它在原理上與React Hot Loader非常相似: https : //github.com/gaearon/react-transform-boilerplate
它已被棄用,但在版本3發布之前,React Hot Loader也是如此。
不可否認,這種“解決方案”可能就像是用大錘敲打釘子。 希望有人可以提供更簡單的東西,不需要交換一堆依賴項和構建配置。
克里斯蒂安的榜樣解決了我的問題。 如果要使用捆綁包,則必須自定義webpack.config文件。 這可以通過谷歌搜索解決,但我花了很多時間來了解Node和Express如何工作......
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.