==============
- node
^4.2.0
- npm
^3.0.0
- React (
^0.14.0
)- Includes react-addons-test-utils (
^0.14.0
)
- Includes react-addons-test-utils (
- Redux (
^3.0.0
)- react-redux (
^4.0.0
) - redux-devtools
- use
npm run dev:nw
to display them in a separate window.
- use
- redux-thunk middleware
- react-redux (
- react-router (
^2.0.0
) - react-router-redux (
^3.0.0
) - Webpack
- CSS modules!
- sass-loader
- postcss-loader with cssnano for style autoprefixing and minification
- Bundle splitting for app and vendor dependencies
- CSS extraction during builts that are not using HMR (like
npm run compile
) - Loaders for fonts and images
- Koa (
^2.0.0-alpha
)- webpack-dev-middleware
- webpack-hot-middleware
- Karma
- Mocha w/ chai, sinon-chai, and chai-as-promised
- Airbnb's Enzyme with chai-enzyme
- PhantomJS
- Code coverage reports
- Babel (
^6.3.0
)- babel-plugin-transform-runtime so transforms aren't inlined
- babel-preset-react-hmre for:
- react-transform-hmr (HMR for React components)
- redbox-react (visible error reporting for React components)
- babel-plugin-transform-react-constant-elements save some memory allocation
- babel-plugin-transform-react-remove-prop-types remove
PropTypes
- ESLint
- Uses Standard Style by default, but you're welcome to change this!
- Includes separate test-specific
.eslintrc
to support chai assertions
先装一个淘宝npm镜像cnpm
$ git clone https://github.com/davezuko/react-redux-starter-kit.git
$ cd react-redux-starter-kit
$ sudo cnpm install # Install Node modules listed in ./package.json (may take a while the first time)
$ npm start # Compile and launch
开发脚本简介
-
本地开发,redux新建窗口?
npm run dev:nw
-
本地开发, redux内嵌窗口?
npm start
-
本地开发 redux不出现?
npm run dev:no-debug
-
线上发布?
npm run deploy
-
- tc环境?
npm run deploy:tc"
- tc环境?
-
- ic环境?
npm run deploy:ic
- ic环境?
-
npm run compile
- Compiles the application to disk (~/dist
by default). -
npm run test
- Runs unit tests with Karma and generates a coverage report. -
npm run test:dev
- Runs Karma and watches for changes to re-run tests; does not generate coverage reports. -
npm run lint
- Lint all.js
files. -
npm run lint:fix
- Lint and fix all.js
files. Read more on this.
NOTE: Deploying to a specific environment? Make sure to specify your target NODE_ENV
so webpack will use the correct configuration. For example: NODE_ENV=production npm run compile
will compile your application with ~/build/webpack/_production.js
.
基础配置 ~/config/_base.js
. For the most part, you should be able to make changes in here without ever having to touch the webpack build configuration. If you need environment-specific overrides, create a file with the name of target NODE_ENV
prefixed by an _
in ~/config
(see ~/config/_production.js
for an example).
Common configuration options:
dir_src
- application source code base pathdir_dist
- path to build compiled application toserver_host
- hostname for the Koa serverserver_port
- port for the Koa servercompiler_css_modules
- whether or not to enable CSS modulescompiler_devtool
- what type of source-maps to generate (set tofalse
/null
to disable)compiler_vendor
- packages to separate into to the vendor bundle
The folder structure provided is only meant to serve as a guide, it is by no means prescriptive. It is something that has worked very well for me and my team, but use only what makes sense to you.
.
├── bin # Build/Start scripts
├── build # All build-related configuration
│ └── webpack # Environment-specific configuration files for webpack
├── config # Project configuration settings
├── server # Koa application (uses webpack middleware)
│ └── main.js # Server application entry point
├── src # Application source code
│ ├── components # 全局的通用组件(必须以.jsx结尾)
│ ├── containers # redux的container组件
│ ├── help # 全局的工具包
│ ├── layouts # 全页面布局
│ ├── redux
│ │ ├── middleware # redux中间件
│ │ ├── modules # reudx单路由(页面)模块。
│ │ └── utils # Redux-specific helpers
│ ├── routes # 路由配置
│ ├── static # Static assets (not imported anywhere in source code)
│ ├── styles # Application-wide styles (generally settings)
│ ├── views # 单路由(页面)
│ └── main.js # Application bootstrap and rendering
└── tests # Unit tests
You can redefine which packages to bundle separately by modifying compiler_vendor
in ~/config/_base.js
. These default to:
[
'history',
'react',
'react-redux',
'react-router',
'react-router-redux',
'redux'
]
Webpack is configured to make use of resolve.root, which lets you import local packages as if you were traversing from the root of your ~/src
directory. Here's an example:
// current file: ~/src/views/some/nested/View.js
// What used to be this:
import SomeComponent from '../../../components/SomeComponent'
// Can now be this:
import SomeComponent from 'components/SomeComponent' // Hooray!
These are global variables available to you anywhere in your source code. If you wish to modify them, they can be found as the globals
key in ~/config/_base.js
. When adding new globals, also add them to ~/.eslintrc
.
process.env.NODE_ENV
- the activeNODE_ENV
when the build started__DEV__
- True whenprocess.env.NODE_ENV
isdevelopment
__PROD__
- True whenprocess.env.NODE_ENV
isproduction
-
__TCPROD__
- True when IC集成编译
-
__ICPROD__
- True when TC集成编译
__TEST__
- True whenprocess.env.NODE_ENV
istest
__DEBUG__
- True whenprocess.env.NODE_ENV
isdevelopment
and cli arg--no_debug
is not set (npm run dev:no-debug
)__BASENAME__
- npm history basename option
This is most likely because the new window has been blocked by your popup blocker, so make sure it's disabled before trying again.被浏览器拦截了窗口了。
Reference: issue 110
While this is common to any sizable application, it's worth noting for those who may not know: if you happen to notice higher CPU usage in your editor after compiling the application, you may need to tell your editor not to process the dist folder. For example, in Sublime you can add:
"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS", "node_modules", "dist"]