MCPcopy Create free account
hub / github.com/FastLED/FastLED / build_dist

Function build_dist

ci/esbuild_frontend.py:143–205  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

141
142
143def build_dist() -> Path:
144 dist_dir = FRONTEND_DIR / "dist"
145 marker = dist_dir / ".esbuild_marker"
146 source_mtime = _get_source_mtime(FRONTEND_DIR)
147 if dist_dir.exists() and marker.exists():
148 try:
149 if float(
150 marker.read_text(encoding="utf-8").strip()
151 ) >= source_mtime and _has_required_static_dist_assets(dist_dir):
152 return dist_dir
153 except ValueError:
154 pass
155
156 if dist_dir.exists():
157 shutil.rmtree(dist_dir)
158 dist_dir.mkdir(parents=True, exist_ok=True)
159
160 _run_esbuild(
161 [
162 str(FRONTEND_DIR / "app.ts"),
163 "--bundle",
164 "--format=esm",
165 "--platform=browser",
166 "--target=es2021",
167 "--sourcemap",
168 f"--outfile={FRONTEND_DIR / 'dist' / 'app.js'}",
169 "--log-level=warning",
170 ]
171 )
172 _run_esbuild(
173 [
174 str(FRONTEND_DIR / "modules" / "core" / "fastled_background_worker.ts"),
175 "--bundle",
176 "--format=esm",
177 "--platform=browser",
178 "--target=es2021",
179 "--sourcemap",
180 f"--outfile={FRONTEND_DIR / 'dist' / 'fastled_background_worker.js'}",
181 "--log-level=warning",
182 ]
183 )
184
185 index_html = (
186 (FRONTEND_DIR / "index.html")
187 .read_text(encoding="utf-8")
188 .replace("./app.ts", "./app.js")
189 )
190 (dist_dir / "index.html").write_text(index_html, encoding="utf-8")
191 _copy_file(FRONTEND_DIR / "index.css", dist_dir / "index.css")
192 _copy_file(
193 FRONTEND_DIR / "modules" / "utils" / "json_inspector.css",
194 dist_dir / "modules" / "utils" / "json_inspector.css",
195 )
196 _copy_file(
197 FRONTEND_DIR / "modules" / "audio" / "audio_worklet_processor.js",
198 dist_dir / "audio_worklet_processor.js",
199 )
200 assets_dir = FRONTEND_DIR / "assets"

Callers 1

copy_dist_to_outputFunction · 0.85

Calls 5

_get_source_mtimeFunction · 0.85
_run_esbuildFunction · 0.85
_copy_fileFunction · 0.85
_copy_treeFunction · 0.85

Tested by

no test coverage detected