Configuration
SALVO-TS is configured through the salvo.config.js file in the root of the project.
This file must export an object which matches the configuration structure. The file is JS rather than JSON, so you can add comments and perform calculations to build your configuration.
Reference
| Item | Description | Default |
|---|---|---|
buildVariant | Controls which build variant the compiler builds. | undefined |
entry | Main entry point for the theme javascript. Relative to root directory. Specified as an array - additional files will all be merged into the same entry point. | ['./src/main.ts'] |
css | Main entry point for the theme stylesheet. Relative to root directory. Specified as an array - additional files will all be merged into the same entry point. | ['./assets/styles/theme.scss'] |
output.themeJs | Specifies asset name of the main theme javascript. | theme.min.js |
output.themeCss | Specifies asset name of the main theme stylesheet. | theme.css.liquid |
extraCss | Specifies additional extra css to build. | [] |
alias | Specifies path aliases for imports. | {'@': path.resolve('./src/'), '@assets': path.resolve('./assets/')} |
components.sass.defaultImports | An array of SCSS files to automatically import into every component stylesheet, used to share variables with components. | ['./assets/styles/variables.scss'] |
components.sass.cssBuildMode | Method for loading component CSS. One of:
| "auto" |
component.sass.cssInlineLimit | Size limit at which to switch from inline to auto behavior (when cssBuildMode is auto) | 8192 |
optimization.sourcemaps | Enable or disable sourcemaps. One of:
| undefined |
optimization.cwvOverlay | Enables or disable the CWV overlay. One of:
| true |
optimization.minify | Enables or disable minification. One of:
| "production" |
optimization.previewBar | Show or hide the Shopify theme preview bar One of:
| undefined |
optimization.preloader | One of:
| undefined |
optimization.preloaderDelay | Maximum time to show the preloader | 200 |
optimization.preloadComponents | Array of components to always load immediately. Use this to specify above-the-fold global components. | [] |
optimization.eagerComponentPreloading | Attempt to determine which components to preload from Liquid. | false |
optimization.icons | Enables optimization of SVG icons | |
optimization.icons.convertToCurrentColor | Converts all colors in SVG icons to currentColor | true |
optimization.devBuildReminder | Shows reminders against publishing themes build in dev mode. One of:
| "enforce" |
optimization.includeCriticalCss | Whether critical styles are included in the theme output One of:
| "always" |
extendVite | Extend the underlying Vite config. Type: extendVite(config: UserConfig): UserConfig | undefined |
depCheck.ignore | Array of package names to exclude from dependency validation | [] |
Type hinting
The type for the expected config exported from salvo.config.js is made available at @eastsideco/salvo-ts-build/schemas/config. You can reference this in a comment in your salvo.config.js file in order to see helpful descriptions of configuration settings and receive feedback in your editor when the config is incorrect.
To enable type hinting include an @type comment on the config object you export and a // @ts-check comment as the first line of the file:
salvo.config.jsjs// @ts-checkconstpath =require ('path');/** @type {import('@eastsideco/salvo-ts-build/schema/config').SalvoConfig} */constconfig = {buildVariant : null,entry : ['./src/main.ts'],css : ['./assets/styles/theme.scss'],output : {themeJs : 'theme.min.js',themeCss : 'theme.css.liquid',themeMetadata : 'theme.metadata.js',},extraCss : [],components : {sass : {defaultImports : [],cssBuildMode : 'inline',},},alias : {},polyfills : [],enableLegacySalvoLiteComponentSupport : false,extendVite (config ) {},optimization : {Type '"small"' is not assignable to type '"block" | "mini" | undefined'.2322Type '"small"' is not assignable to type '"block" | "mini" | undefined'.: 'small' previewBar }};module .exports =config ;
salvo.config.jsjs// @ts-checkconstpath =require ('path');/** @type {import('@eastsideco/salvo-ts-build/schema/config').SalvoConfig} */constconfig = {buildVariant : null,entry : ['./src/main.ts'],css : ['./assets/styles/theme.scss'],output : {themeJs : 'theme.min.js',themeCss : 'theme.css.liquid',themeMetadata : 'theme.metadata.js',},extraCss : [],components : {sass : {defaultImports : [],cssBuildMode : 'inline',},},alias : {},polyfills : [],enableLegacySalvoLiteComponentSupport : false,extendVite (config ) {},optimization : {Type '"small"' is not assignable to type '"block" | "mini" | undefined'.2322Type '"small"' is not assignable to type '"block" | "mini" | undefined'.: 'small' previewBar }};module .exports =config ;
Due to a Typescript bug this will not work if you specify the @type comment on a direct assignment to module.exports. Instead, you need to use an intermediary variable as shown in the example above:
salvo.config.jsts// @ts-check// This will not work/** @type {import('@eastsideco/salvo-ts-build/schema/config').SalvoConfig} */module .exports = {// ...};
salvo.config.jsts// @ts-check// This will not work/** @type {import('@eastsideco/salvo-ts-build/schema/config').SalvoConfig} */module .exports = {// ...};