美文网首页
0.7 Development and Production V

0.7 Development and Production V

作者: 人头原子弹 | 来源:发表于2017-03-08 21:54 被阅读0次

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

    默认情况下React内置了很多有用的警告。这些警告对开发很有帮助。

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

    但是,它们使React更大更慢,因此您应该在部署应用程序时确保使用生产版本。

    Create React App 创建React应用

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

    如果你使用创建React应用,npm run build 将会创建您的应用程序的优化构建到build文件夹。

    Webpack Webpack

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

    按照指南上说的那样把DefinePlugin和UglifyJsPlugin引入到Webpack生产配置中。

    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.

    运行Browserify,将NODE_ENV环境变量设置为生产配置,并使用UglifyJS作为最后一个构建步骤,以便只有开发代码被删除。

    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(按顺序)删除仅开发代码。有关完整的设置示例,请参阅此处。

    相关文章

      网友评论

          本文标题:0.7 Development and Production V

          本文链接:https://www.haomeiwen.com/subject/lwjigttx.html