0.7 Development and Production Versions 開發(fā)和生產(chǎn)版本

By default, React includes many helpful warnings.These warnings are very useful in development.

默認(rèn)情況下React內(nèi)置了很多有用的警告。這些警告對(duì)開發(fā)很有幫助。

However, they make React larger and slower so you should make sure to use the production version when you deploy the app.

但是,它們使React更大更慢,因此您應(yīng)該在部署應(yīng)用程序時(shí)確保使用生產(chǎn)版本。

Create React App 創(chuàng)建React應(yīng)用

If you use Create React App, npm run build will create an optimized build of your app in the build folder.

如果你使用創(chuàng)建React應(yīng)用,npm run build 將會(huì)創(chuàng)建您的應(yīng)用程序的優(yōu)化構(gòu)建到build文件夾。

Webpack Webpack

Include both DefinePlugin and UglifyJsPlugin into your production Webpack configuration as described in this guide.

按照指南上說的那樣把DefinePlugin和UglifyJsPlugin引入到Webpack生產(chǎn)配置中。

Browserify Browserify

Run Browserify with NODE_ENV environment variable set to production and use UglifyJS as the last build step so that development-only code gets stripped out.

運(yùn)行Browserify,將NODE_ENV環(huán)境變量設(shè)置為生產(chǎn)配置,并使用UglifyJS作為最后一個(gè)構(gòu)建步驟,以便只有開發(fā)代碼被刪除。

Rollup Rollup

Use rollup-plugin-replace plugin together with rollup-plugin-commonjs (in that order) to remove development-only code. See this gist for a complete setup example.

使用rollup-plugin-replace插件和rollup-plugin-commonjs(按順序)刪除僅開發(fā)代碼。有關(guān)完整的設(shè)置示例,請(qǐng)參閱此處。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容