我已经构建了一个 react 应用程序,它运行在 localhost:8080 ,现在我想将其更改为 0.0.0.0:80 使其公开访问,但遗憾的是我无法访问。
Webpack file:
var config = {
entry: [
'./main.js'
],
output: {
path:'D:\\reactApps\\RouterExample',
filename: 'index.js',
},
devServer: {
inline: true,
host: '0.0.0.0',
port: 80,
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
},{
test: /\.css$/,
exclude: /node_modules/,
loader: 'style-loader'
}, {
test: /\.css$/,
exclude: /node_modules/,
loader: 'css-loader',
query: {
modules: true,
localIdentName: '[name]__[local]___[hash:base64:5]'
}
}
]
}
}
module.exports = config;
package.json file:
{
"name": "routerexample",
"version": "1.0.0",
"description": "new app",
"main": "index.js",
"dependencies": {
"axios": "^0.16.2",
"babel-core": "^6.25.0",
"babel-loader": "^7.1.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.4",
"react": "^15.6.1",
"react-autocomplete": "^1.7.1",
"react-bootstrap": "^0.31.1",
"react-bootstrap-alert": "^1.0.7",
"react-bootstrap-dialog": "^0.9.1",
"react-bootstrap-typeahead": "^2.0.0-alpha.3",
"react-dom": "^15.6.1",
"react-number-format": "^3.0.2",
"react-router": "^4.1.2",
"react-router-dom": "^4.1.2",
"style-loader": "^0.18.2",
"underscore": "^1.8.3",
"webpack": "^3.3.0",
"webpack-dev-server": "^2.5.1"
},
"scripts": {
"start": "webpack-dev-server --hot --history-api-fallback"
},
"author": "",
"license": "ISC"
}
编辑-1:
我想将我的应用程序配置为可通过url访问,例如(xyz.com)而不是localhost,它是如何实现的??
提前感谢您的建议。