agentleFS
ivangrynenkoivangrynenko/cursorrules/.cursor/rules/build-optimization.mdc

cursorrules / rules

Cursor rule88 starsChanged 13 months agoMITView on GitHub

Webpack/Vite configuration and build process optimization

  • Reads credentials

The file

We split this build-optimization.mdc into the rules it gives an agent

6 rules. About 0 are common, 6 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use lazy loading for images and other media.

    line 33
  2. Distinctive:

    Use long-term caching for static assets with content hashing in filenames.

    line 36
  3. Distinctive:

    Use ES6+ features but ensure polyfills for older browsers if needed.

    line 38
  4. Distinctive:

    Consider using features like module/nomodule for graceful degradation.

    line 39
  5. Distinctive:

    Minification & Compression: Ensure all JavaScript and CSS are minified and consider enabling gzip compression on the server.

    line 40
  6. Distinctive:

    Environment Variables: Use environment variables for configuration differentiation between development and production.

    line 42

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
build-optimization.mdc
---
description: Webpack/Vite configuration and build process optimization
globs: webpack.config.js, vite.config.js, *.config.js
---
# Enhanced Build Process Optimization

Ensures optimal build configuration and process for better performance and maintainability.

## Rule Details

- **Name:** enhanced_build_optimization

- **Description:** Enforce standards for optimizing build processes

## Filters
- file extension pattern: `"\\.(js|ts|json)$"  # Expanded to cover more config file types`

## Enforcement Checks
- Conditions:
  - pattern `mode:\\s*['\"]development['\"]` – negated `process\\.env\\.NODE_ENV === 'development'` – Set 'mode' to 'production' for production builds unless dynamically set by NODE_ENV.
  - pattern `devtool:\\s*['\"]eval` – Use 'source-map' or 'hidden-source-map' for production builds to balance performance and debugging.
  - pattern `optimization:\\s*{[^}]*?splitChunks:\\s*{[^}]*?chunks:\\s*(?!'all')` – Enable code splitting for all chunks in optimization settings.
  - pattern `optimization:\\s*{[^}]*?usedExports:\\s*(?!true)` – Enable tree shaking by setting 'usedExports' to true.
  - pattern `output\\s*:\\s*{[^}]*?filename:\\s*['\"][^\\[]+['\"]` – Use content hashing in filenames for better caching (e.g., '[name].[contenthash].js').

## Suggestions
- Guidance:
**Build Optimization Best Practices:**
- **Code Splitting:** Implement code splitting to load only what's necessary for each page or component.
- **Tree Shaking:** Enable tree shaking to eliminate dead code, which reduces bundle size.
- **Asset Optimization:**
  - Compress images and use modern formats like WebP where supported.
  - Use lazy loading for images and other media.
- **Caching:**
  - Configure proper caching strategies (e.g., HTTP headers, service workers for PWA).
  - Use long-term caching for static assets with content hashing in filenames.
- **Modern JavaScript:** 
  - Use ES6+ features but ensure polyfills for older browsers if needed.
  - Consider using features like module/nomodule for graceful degradation.
- **Minification & Compression:** Ensure all JavaScript and CSS are minified and consider enabling gzip compression on the server.
- **Performance Budgets:** Set performance budgets to keep bundle sizes in check.
- **Environment Variables:** Use environment variables for configuration differentiation between development and production.
- **CI/CD:** Integrate with CI/CD pipelines for automated builds and testing, ensuring only optimized code goes to production.

## Metadata
- Priority: high
- Version: 1.2

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.