1.0.7 • Published 1 year ago

@wz-libs/rc-service v1.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

React Start or build

Environment

  • node v12.13.0+
  • webpack v5.38+
  • webpack-cli v4.9+
  • webpack-dev-server v4.7+

1、Git clones use projects

git clone https://gitee.com/my_domain/rc-react-project.git

cd rc-react-project

yarn 

yarn start

2、Replace to use

Install

npm install @wz-libs/rc-service -D

or

yarn add @wz-libs/rc-service -D

command

commandexplainremark
startThe development environment runs commandsyarn start / npm run start
buildThe production environment runs commandsyarn build / npm run build
analyse --developmentDevelopment environment performance analysisyarn analyse --development / npm run analyse --development
analyse --productionProduction environment performance analysisyarn analyse --production / npm run analyse --production

command extend

## Note: if APP_ENV is not set and exists, the. Env file will be loaded by default

Read environment variables from files .env.[APP_ENV]
Example: npm run start -m dev
npm run start -m [APP_ENV] Or npm run start --mode [APP_ENV]

npm run build -m [APP_ENV] Or npm run build --mode [APP_ENV]

directory

├── public                      // Static resource file
│   ├── index.html              // index.html
├── src                         // Important folder
│   ├── index.js                // React run and webpack compile entry file The must
│   ├── App.js                  // Render route page
│   ├── pages                   // React pages
│   ├── assets                  // assets
├── .env/.env.[APP_ENV]        // Environment Variable Configuration
├── rcw.config.js               // custom webpack config
├── .babelrc                    // babel config
├── package.json                // package.json

rcw.config.js

### The global environment variable NODE_ENV is the built-in variable

const { merge } = require('webpack-merge')
module.exports = {
    webpackConfig: (config,isDev, APP_ENV) => {
        return merge(config, {
            // your webpack config
        });
    }
}

package.json

"scripts": {
    "start": "rc-service start",  // The development of start
    "build": "rc-service build", // The deployment of building
    "analyse:dev": "rc-service analyse --development", // Development environment performance analysis
    "analyse:prod": "rc-service analyse --production" // Production environment performance analysis
  },
"dependencies": {
  "react": "^17.0.2",
  "react-dom": "^17.0.2",
  "react-router-dom": "^6.2.1"
},
"devDependencies": {
  "@wz-libs/rc-service": "^1.0.0"
}