React实践相关

语法高亮:

sublime ctrl+shift+P 安装babel ,在view-syntax-open all width current extension as...-babel-js(babel)即可。

Sublime Text 3 搭建 React.js 开发环境

*开发工具: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/react@15/dist/react.min.js"></script>
2 <script src="https://unpkg.com/react-dom@15/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中要包含这些插件。

//待续

原文地址:https://www.cnblogs.com/alan2kat/p/7478325.html