メインコンテンツまでスキップ
バージョン: v4.36

Command Line Interface (CLI)

Stencil's command line interface (CLI) is how developers can build their projects, run tests, and more. Stencil's CLI is included in the compiler, and can be invoked with the stencil command in a project where @stencil/core is installed.

stencil build​

Stencilプロジェクトをビルドします。以下のフラグはbuildコマンドで利用可能なオプションです。

FlagDescriptionAlias
--ci継続的インテグレーション(CI)環境の推奨設定を使用してビルドを実行します。ワーカーの数はデフォルトで4に設定されており、テストでスクリーンショットを取ると、コンソールのログを変更し追加で時間がかかります。
--configstencil.config.tsファイルのパス。Stencilがconfigを見つけるので、このフラグはほとんどの場合必要ありません。さらに、Stencilのconfigは必須ではありません。-c
--debugデバッグに役立つランタイムコードを追加し、より詳細なログの出力レベルを設定します。
--dev開発ビルドを実行します。
--docsGenerate all docs based on the component types, properties, methods, events, JSDocs, CSS Custom Properties, etc.
--es5ES5互換のビルドを作成します。デフォルトではビルド時間を短縮するため、開発中はES5ビルドを作成しません。ただし、プロダクションビルド中は常にES5ビルドを作成します。このフラグを使用すると、開発中にもES5ビルドを作成します。
--logstencil buildのログをstencil-build.logに出力します。ログファイルはconfigと同じディレクトリに出力されます。
--prerenderビルド完了後、www出力ターゲットを使用してアプリケーションを事前にレンダリングします。
--prodバンドルの改善や未使用のコードを削除、最小化するなど、各ファイルを最適化して本番ビルドを実行します。本番ビルドはデフォルトであり、このフラグは--devフラグを上書きする時のみに使用されます。
--max-workersコンパイラが使用するワーカーの最大数。デフォルトでは、OSで使用可能なCPUの数を使用します。
--next"次期の"Stencilコンパイラ機能をテストするためのオプトイン。
--no-cacheキャッシュの使用を無効にします。
--no-openBy default the --serve command will open a browser window. Using the --no-open command will not automatically open a browser window.
--portIntegrated Dev Serverのポート。 デフォルトは"3333"です。-p
--serveIntegrated Dev Serverを起動します.
--statsプロジェクトに関する統計を stencil-stats.jsonに出力します。統計ファイルは、configと同じ場所に出力されます。
--verboseビルドの各ステップに関する追加情報をログに記録します。
--watch開発中にファイルを監視し、ファイルが更新されると再ビルドします。

stencil docs​

Performs a one-time generation of documentation for your project. For more information on documentation generation, please see the Documentation Generation section.

備考

This command runs with dev mode enabled, which does not run a full build. As a result, documentation that needs to be built first, like CSS styles, will not be generated. You will need to run npx stencil build --docs to generate documentation that requires building.

stencil generate​

Alias: stencil g

Starts the interactive generator for a new Stencil component. The generator will ask you for a name for your component, and whether any stylesheets or testing files should be generated.

If you wish to skip the interactive generator, a component tag name may be provided on the command line:

stencil generate my-new-component

All components will be generated within the src/components folder. Within src/components, a directory will be created with the same name as the component tag name you provided containing the generated files. For example, if you specify page-home as the component tag name, the files will be generated in src/components/page-home:

src
└── components
└── page-home
├── page-home.css
├── page-home.e2e.ts
├── page-home.spec.ts
└── page-home.tsx

It is also possible to specify one or more sub-folders to generate the component in. For example, if you specify pages/page-home as the component tag name, the files will be generated in src/components/pages/page-home:

stencil generate pages/page-home

The command above will result in the following directory structure:

src
└── components
└── pages
└── page-home
├── page-home.css
├── page-home.e2e.ts
├── page-home.spec.ts
└── page-home.tsx

stencil help​

Aliases: stencil --help, stencil -h

Prints various tasks that can be run and their associated flags to the terminal.

stencil test​

Stencilプロジェクトをテストします。以下のフラグはtestコマンドで利用可能なオプションです。

フラグ説明
--specJestを使用して .spec.tsファイルをテストします。
--e2ePuppeteerとJestを使用して.e2e.tsファイルをテストします。
--no-buildSkips the build process before running end-to-end tests. When using this flag, it is assumed that your Stencil project has been built prior to running stencil test. Unit tests do not require this flag.
--devtoolsOpens the dev tools panel in Chrome for end-to-end tests. Setting this flag will disable --headless
--headlessSets the headless mode to use in Chrome for end-to-end tests. --headless and --headless=true will enable the "old" headless mode in Chrome, that was used by default prior to Chrome v112. --headless=new will enable the new headless mode introduced in Chrome v112. See this article for more information on Chrome's new headless mode.

stencil version​

Aliases: stencil -v, stencil --version

Prints the version of Stencil to the terminal.