【发布时间】:2019-07-02 14:40:23
【问题描述】:
我想使用 superstatic 和 React 来托管我的构建文件。
运行npm run host 后,我的文件被构建并启动了超静态。
参见下面的代码。
package.json - './application/dist' 是我的构建文件
"scripts": {
"start": "webpack-dev-server --mode development --open",
"build": "npm run lint && webpack --mode production",
"host": "npm run build && superstatic ./application/dist --port 3000",
"test": "jest",
"lint": "eslint . --ext .js,.ts,.tsx",
"lint:fix": "npm run lint -- --fix"
},
"devDependencies": {...},
"dependencies": {
"@material-ui/core": "^4.0.1",
"connected-react-router": "^6.4.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-helmet": "^5.2.1",
"react-redux": "^7.0.3",
"react-router-dom": "^5.0.0",
"redux": "^4.0.1",
"redux-saga": "^1.0.2",
"superstatic": "^6.0.4"
}
superstatic.json
{
"rewrites": [
{
"source": "*",
"destination": "/index.html"
}
]
}
我得到了什么:
当我打开 localhost:3000 时,我可以看到我的应用程序,但是当我刷新浏览器时,我得到“Cannot GET /some_url”。
我想要什么:
我希望获得 /some url 上的内容,但我得到的是“Cannot GET /some_url”。
有谁知道如何解决这个问题?
【问题讨论】:
标签: reactjs webpack react-router