*开发工具:React Developer Tools for Chrome
*Create React App方式创建React App: Create React App
npm run build
npm run build是部署生产版本的时候用到的,平时开发用npm run strat即可。
*生产版本的React and React DOM文件:
1 <script src="https://unpkg.com/[email protected]/dist/react.min.js"></script> 2 <script src="https://unpkg.com/[email protected]/dist/react-dom.min.js"></script>
.min.js后缀的文件才适合用在生产版本。
*glify-js-brunch
plugin:打包生成production build
1 # If you use npm 2 npm install --save-dev uglify-js-brunch 3 4 # If you use Yarn 5 yarn add --dev uglify-js-brunch 6 7 //Then, to create a production build, add the -p flag to the build command: 8 brunch build -p
*Webpack:
Note:
If you‘re using Create React App, please follow the instructions above.
This section is only relevant if you configure webpack directly.
new webpack.DefinePlugin({ ‘process.env‘: { NODE_ENV: JSON.stringify(‘production‘) } }), new webpack.optimize.UglifyJsPlugin()
在项目的config.js中要包含这些插件。
//待续
时间: 2024-10-10 06:15:29