|
| 1 | +# Build Configuration Notes |
| 2 | + |
| 3 | +This document explains specific workarounds implemented in this project to address build issues in cloud environments. |
| 4 | + |
| 5 | +## Segmentation Fault (SIGSEGV) Fix |
| 6 | + |
| 7 | +The project uses several settings to prevent segmentation faults during the build process on platforms like Vercel and Netlify: |
| 8 | + |
| 9 | +### 1. Disabled Parcel Workers (`PARCEL_WORKERS=0`) |
| 10 | + |
| 11 | +**Location:** `package.json` build script |
| 12 | +```json |
| 13 | +"build": "PARCEL_WORKERS=0 NODE_OPTIONS=--max-old-space-size=1024 parcel build src/index.html" |
| 14 | +``` |
| 15 | + |
| 16 | +**Purpose:** Prevents Parcel from using multi-threading, which can cause memory issues in constrained CI environments. Fixes SIGSEGV crashes that occur after the build completes. |
| 17 | + |
| 18 | +### 2. Memory Limitations (`NODE_OPTIONS=--max-old-space-size=1024`) |
| 19 | + |
| 20 | +**Location:** `package.json` build script |
| 21 | +```json |
| 22 | +"build": "PARCEL_WORKERS=0 NODE_OPTIONS=--max-old-space-size=1024 parcel build src/index.html" |
| 23 | +``` |
| 24 | + |
| 25 | +**Purpose:** Explicitly limits Node.js memory allocation to 1GB to prevent aggressive memory usage that might lead to segmentation faults. |
| 26 | + |
| 27 | +### 3. Disabled CSS Optimizers |
| 28 | + |
| 29 | +**Location:** `.parcelrc` |
| 30 | +```json |
| 31 | +"optimizers": { |
| 32 | + "*.css": [] |
| 33 | +} |
| 34 | +``` |
| 35 | + |
| 36 | +**Purpose:** Completely disables Parcel's CSS optimizers (particularly LightningCSS) which are often the cause of segmentation faults in build environments. |
| 37 | + |
| 38 | +### 4. Optimization Disabled in Targets |
| 39 | + |
| 40 | +**Location:** `package.json` targets section |
| 41 | +```json |
| 42 | +"targets": { |
| 43 | + "default": { |
| 44 | + "optimize": false |
| 45 | + } |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +**Purpose:** Disables Parcel's default optimizers to prevent memory issues and crashes. |
| 50 | + |
| 51 | +## PostCSS Configuration |
| 52 | + |
| 53 | +### CSS Comments Handling |
| 54 | + |
| 55 | +**Location:** `.postcssrc` and `package.json` devDependencies |
| 56 | +```json |
| 57 | +// .postcssrc |
| 58 | +{ |
| 59 | + "plugins": { |
| 60 | + "postcss-discard-comments": { "removeAll": true }, |
| 61 | + "@tailwindcss/postcss": {} |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +// package.json |
| 66 | +"postcss-discard-comments": "^7.0.4" |
| 67 | +``` |
| 68 | + |
| 69 | +**Purpose:** Addresses the "Cannot read properties of undefined (reading 'input')" error from PostCSS by properly handling CSS comments. |
| 70 | + |
| 71 | +## When to Revisit |
| 72 | + |
| 73 | +These workarounds should be revisited when: |
| 74 | +1. Updating Parcel to a new major version |
| 75 | +2. Updating Tailwind CSS or PostCSS to new major versions |
| 76 | +3. If build environments (Vercel/Netlify) change their Node.js configurations |
| 77 | + |
| 78 | +The ideal solution would be to use standard configurations without these workarounds, but currently, they're necessary for stable builds in cloud environments. |
0 commit comments