@sidoshi/react-scripts v1.0.9
react-scripts
This is a custom react-scripts package to be used with Create React App. Please refer to its documentation:
- Getting Started – How to create a new app.
- User Guide – How to develop apps bootstrapped with Create React App.
This react-scripts package adds some extra features to official react-scripts:
Sass support - You can now import sass, scss or css files in js code like this:
import 'App.sass'Note: css files are also processed with node-sass webpack loader. Though that wouldn't cause any problem even if you use plain css.
Sass files can also import modules from
sassdirectory insrc. This is to store reusable varibles like colors and config as shown in templateApp.sassandindex.sass. Example:@import "_colors.sass"Now this file has access to all variables declared in
_colors.sass.It is good practice to prefix this files with
_(underscore) like this_colors.sassas files prefixed with_are not compiled to css bynode-sass.Absolute Imports - All direct files under
srccan be imported with absolute path.import App from 'components/App'Note: Files in
srcare given preference overnode_modulesso it would be better to name your files properly.For eg:
import actions from 'actions'If you have a directory or file named
actionsdirectly undersrcthan that will be imported instead ofactionspackage you might have downloaded fromnpm. It would be better to give namespace to files directly undersrclike prefixing them with_so you could import like this:import actions form '_actions'Prettier out of the box - Prettier is installed and setup by default. Just run:
npm run formatAll js files under
src/will be formated by prettier. You can obviously edit theformatscript inpackage.jsonif you don't like the default behaviour.Note: This will run automatically by precommit hooks before you commit, so you can never commit bad code.
Flow built-in - Flow supported by default. Run:
npm run flowAdding flow requires adding some extra configuration and directories. So you may find following extra files in your project.
.flow/- Contains stubs for sass imports. You dont have to ever worry about what's in this directory. You can even configure your editor to hide this directory. But this dir is import to your flow config so you have to commit this..flowconfig- Contains flow config. You can change it to suit your needs. By default it contains decent config so you may not need to change it.flow-typed/- Contains lib-defs of your packages. Again you dont have to worry about this dir.src/interfaces/- Empty directory. You can place your flow types (interfaces) here.Note: This will run automatically by precommit hooks before you commit, so you can never commit bad code.
If you are using vscode, set
javascript.validate.enabeletofalse.Git Hooks - If you are creating the app in existing git repo, then git hooks are already setup for you. Before you commit your code will be automatically formatted using
prettierand tested usingjestandflow, so you can be sure that your code is consistent and bug free. Though if you are not creating the app in an existing git repo, hooks will not be set up. If you want to set it up, you simply need to initialise the repo and runsetup_hooksscript like this:git init npm run setup_hooksOnce you have succesfully run
setup_hooks, there is no need forsetup_hooksscript, So you can remove that script frompackage.json.Storybook - You get storybook setup for you. Any file ending with
.stories.jswill be run by storybook. You can use this to build components in isolation and better document your component. Run:npm run storybook