CLI
Storefront X has its own command-line interface (CLI).
You can run it either directly with package manager (yarn sfx) or add helpful scripts to root package.json.
{
"scripts": {
"dev": "sfx dev",
"build": "sfx build",
"serve": "sfx serve"
}
}Each command has it's own help section, which you can show with the --help flag (yarn dev --help).
dev
Starts the development server. It watches the project files and performs hot-module-reloading for better developer experience.
--portset port for the development server--hostset host for the development server--configset path to the Storefront X configuration file
WARNING
Because development build isn't optimized, initial load might appear to be broken (slow loading, missing styles, etc.). This is a side effect, how Vite serves files to the browser during the development and is non-issue in the production build.
build
Builds the production bundle. The production bundle can be found in the .sfx/dist/ directory.
--configset path to the Storefront X configuration file--analyzeshow visualization of the build JS bundle--onlyBootstraponly generate the.sfxdirectory without building the application
serve
Serves the production bundle.
--portset port for the development server--hostset host for the development server--compressionenable compression of the server output--failOnServerErrorshow internal server error instead of SPA fallback on server error