Use carbon-preprocess-svelte for faster, optimized builds
#234
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Review by commit.
Note: Git diff is massive since the lockfile has not been checked in to source control. Rebase on #235
This is optional, but I recommend incorporating the Carbon preprocessor for faster development/production builds and optimized CSS generation.
Svelte has first-class support for preprocessors. This means that code can be transformed before compilation.
carbon-preprocess-svelteautomatically processes source code to rewrite Carbon imports to their optimized path, greatly reducing the number of initially loaded components.In the case of Carbon, I recommend the following:
optimizeImports: automatically rewrites Carbon imports to the optimized path. Carbon has a lot of exports from its barrel file. Optimizing imports can greatly reduce cold start and build times, since it bypasses the barrel file.optimizeCss: Vite plugin that optimizes CSS fromcarbon-components-svelteat build time.Results
Running locally on my machine, I observe ~1.21x (~17%) faster build times and ~45.8% reduced CSS output size (non-gzip).
npm run build
Optimized CSS