Performance: Build optimization for production
This affects the page load speed by reducing bundle size and improving resource loading efficiency.
vite build --mode production
// or
vue-cli-service build --mode production --modernvite build --mode development
// or
vue-cli-service build --mode development| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Development build | Normal | Multiple due to larger scripts | High due to blocking scripts | [X] Bad |
| Production build with minification | Normal | Single or fewer reflows | Lower paint cost | [OK] Good |
| Import full library | Normal | Multiple reflows due to heavy scripts | High paint cost | [X] Bad |
| Import only used components | Normal | Fewer reflows | Lower paint cost | [OK] Good |
| Unoptimized images | Normal | Reflows triggered by late image load | High paint cost and CLS | [X] Bad |
| Optimized images with lazy loading | Normal | Minimal reflows | Low paint cost and stable layout | [OK] Good |
npm run build in a Vue project?npm run build compiles and optimizes the Vue app for production deployment.npm run dev or npm install.package.json, the correct syntax is npm run <script-name>.npm run build.npm run build in a Vue project, which folder typically contains the optimized production files?src holds source code, public holds static assets, node_modules holds dependencies.dist folder by default.npm run build but the output files are very large. Which of these is NOT a recommended way to reduce the build size?defineAsyncComponent.v-if only hides the component but does not delay loading. Global registration and normal import load the component eagerly.Pass the test and this pattern moves unknown