React雜篇(1) 打包發布注意事項

2022-08-21 00:03:08 字數 1160 閱讀 9872

問題:直接打包會出現一下情況:

方式一:

package.json檔案下加入homepage字段

}

方式二:

webpack相關 ->config/paths.js

const servedurl =

envpublicurl || (publicurl ? url.parse(publicurl).pathname : 『./』); // 配置檔案跟路徑』/』 修改這裡

return ensureslash(servedurl, true);

}專案的體積優化也很重要,開發時的按需載入,模組化分割這裡就不多說了。

打包時,會生成一系列的.map檔案,佔的體積非常大。

webpack相關 ->webpack.config.prod.js

devtool: shouldusesourcemap ? 'source-map' : false,

//變為

devtool: false,

經過上面的配置與修改心想這下總該沒事了吧!

然而事實可能不同:

專案中控制路由跳轉使用的是browserrouter。

在開發過程中使用是沒有問題的,但是將頁面上傳至伺服器之後,問題就來了:使用者訪問的資源不存在,頁面是空白的,就像上面。

原因:

在browserhistory 模式下,url 是指向真實 url 的資源路徑,當通過真實 url 訪問**的時候,由於路徑是指向伺服器的真實路徑,但該路徑下並沒有相關資源,所以使用者訪問的資源不存在。

解決

browserrouter改為hashrouter上面文件並不完善,之後有時間再新增或更改。

併發程式設計雜篇

atomically adds the given value to the current value.param delta the value to add return the updated value public final intaddandget int delta public ...

11 5 19關於T SQL雜篇

建立 或儲存過程檢視神馬的新增的判斷。if exists select from dbo.sysobjects where id object id n dbo proc s score list and objectproperty id,n isprocedure 1 objectpropert...

雜題集萃 1

給出 n 個形如 f i x a ix 2 b i 的二次函式。有 q 次詢問,每次給出乙個 x 詢問 max f i x 第一行兩個整數 n q 接下來的 n 行,每行兩個整數 a i b i 接下來的 q 行,每行乙個整數 x 對於每個詢問,輸出一行乙個整數表示答案。input2 4 3 04 ...