पाठ 21 / 25
Testing और CI/CD integration
Testing और deployment के साथ Webpack को integrate करें।
CI pipelines में build करना
CI/CD pipelines controlled environments में Webpack builds को चलाते हैं। package.json में npm scripts builds को trigger करते हैं। CI environment variables को set करके build behavior को customize करें।
CI/CD build script
CI builds के लिए typical npm scripts।
{
"scripts": {
"build:dev": "webpack --mode development",
"build:prod": "webpack --mode production",
"build:ci": "CI=true npm run build:prod",
"test": "jest --coverage",
"lint": "eslint src/**/*.js"
}
}
Output:
CI runs: npm run lint && npm run test && npm run build:ci
CI में bundles को analyze करें
Webpack-bundle-analyzer का उपयोग करके bundle composition की visual reports generate करें। Bundle size limits को set करें और exceeded होने पर builds fail करें।
त्वरित जाँच
त्वरित जाँच: CI में bundles को क्यों analyze करें?
- Performance regressions को early catch करने के लिए।
- Builds को तेज बनाने के लिए।
- Deployment time को reduce करने के लिए।
Answer
Performance regressions को early catch करने के लिए। — CI में bundle analysis production तक पहुँचने से पहले size increases को detect करता है।