Closed free-pan closed 6 years ago
umi版本: 1.3.18 npm版本: 5.6.0 node版本: 8.11.4 部署方式: 使用 umi build 生成dist目录, 然后将生成的dist目录放到nginx配置的目录下,运行nginx然后访问首页,出现: TypeError: Cannot read property '1' of null at t.value (src__pages__index.33d8e2d2.async.js:1)的异常, 并且页面为空白.
umi build
TypeError: Cannot read property '1' of null at t.value (src__pages__index.33d8e2d2.async.js:1)
其它说明: 使用umi dev运行正常 用到的包:
umi dev
{ "devDependencies": { "prop-types": "^15.6.2", "react-intl": "^2.4.0", "umi-plugin-routes": "^0.1.5" }, "dependencies": { "axios": "^0.18.0", "codemirror": "^5.40.0", "path-to-regexp": "^2.4.0", "prop-types": "^15.6.2", "qs": "^6.5.2", "react-codemirror2": "^5.1.0", "react-intl": "^2.4.0", "umi-plugin-dva": "^0.9.1", "umi-plugin-routes": "^0.1.5" } }
.umirc.js
const path = require("path") export default { alias: { '@support': path.resolve(__dirname, 'src/support/') }, plugins: [ ['umi-plugin-dva', { immer: true }], ['umi-plugin-routes', { exclude: [ /models/, /services/, ], }], ], lessLoaderOptions: { modifyVars: { '@icon-url': '"/iconfont/iconfont"', } }, routes: [ { path: '/', component: 'index', routes: [ { path: '/', component: 'api-detail/ApiDetail' }, { path: '/:tagKey/:apiKey', component: 'api-detail/ApiDetail' } ] }, ] }
nginx配置:
server { listen 8906; server_name localhost; location / { root /Users/hello/static_sites/test-deploy/dist; index index.html index.htm; } }
dist目录包含的文件:
|- index.html |-service-worker.js |-static |---| common-umi.878569e7.async.js |---| iconfont |---| pic |---| src__pages__api-detail__ApiDetail.36e0ce6f.async.js |---| 省略若干文件 |---| umi.46ea3b39.js |---| umi.afcfeaf9.css
源码目录:
|-- project-dir |-- | --| public //里面放了一些(图片,字体图标) |-- | --| src |-- | --| --| locales |-- | --| --| models |-- | --| --| pages |-- | --| --| services |-- | --| --| support |-- | --| --| dva.js |-- | --| --| global.less |-- | --| .umric.js |-- | --| package.js
给个可重现的代码吧,看描述不能确定问题原因。
@free-pan 请问build的时候,怎么把css、js文件打包到static文件夹下的?
umi版本: 1.3.18 npm版本: 5.6.0 node版本: 8.11.4 部署方式: 使用
umi build
生成dist目录, 然后将生成的dist目录放到nginx配置的目录下,运行nginx然后访问首页,出现:TypeError: Cannot read property '1' of null at t.value (src__pages__index.33d8e2d2.async.js:1)
的异常, 并且页面为空白.其它说明: 使用
umi dev
运行正常 用到的包:.umirc.js
nginx配置:
dist目录包含的文件:
源码目录: