Build For Production
By default, Farm has enabled support for the following features for production builds:
Tree Shake
: Crop and filter irrelevant modules and codeCompression
: Compress and mix the product to reduce the product volumeAutomatically inject Polyfill
: Farm downgrades projects to ES5 by default, which means that the products built by Farm can run on almost all browsersAutomatic partial packaging
: Based on dependencies and size, the project is partially packaged. For each resource request, about 25 resources are generated to ensure parallel loading performance and improve cache hits as much as possible. Rate
Add build scriptâ
Add build script in package.json
:
package.json
{
"name": "1-create-a-project",
"version": "1.0.0",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "farm start",
"build": "farm build"
},
// ...ignore other fields
}
Then execute npm run build
.