Skip to content

Commit

Permalink
fix(compiler): Enable custom tasks to be called up in watch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Sukaato authored and Sukaato committed Apr 16, 2024
1 parent 5838a0c commit 055139c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/compiler/output-targets/output-custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import type * as d from '../../declarations';
import { generateDocData } from '../docs/generate-doc-data';

export const outputCustom = async (config: d.ValidatedConfig, compilerCtx: d.CompilerCtx, buildCtx: d.BuildCtx) => {
const task = config.devMode ? 'run' : 'build';
const docsData = await generateDocData(config, compilerCtx, buildCtx);
const task = config.watch ? 'always' : 'onBuildOnly';
const customOutputTargets = config.outputTargets
.filter(isOutputTargetCustom)
.filter((o) => (o.task === undefined ? true : o.task === task));
.filter((o) => (o.taskShouldRun === undefined ? true : o.taskShouldRun === task));

if (customOutputTargets.length === 0) {
return;
}
const docsData = await generateDocData(config, compilerCtx, buildCtx);

await Promise.all(
customOutputTargets.map(async (o) => {
Expand Down
12 changes: 7 additions & 5 deletions src/declarations/stencil-public-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2241,12 +2241,14 @@ export interface OutputTargetCustom extends OutputTargetBase {
type: 'custom';
name: string;
/**
* Indicate in wich mode the output target has to be executed.
* By default if nothing is specified it run for both.
* - `"run"`: Executed in dev mode on every change in your code
* - `"build"`: Executed only on build
* Indicate when the output target should be executed.
*
* - `"onBuildOnly"`: Executed only when `stencil build` is called without `--watch`.
* - `"always"`: Executed on every build, including in `watch` mode.
*
* Defaults to "always".
*/
task?: 'run' | 'build';
taskShouldRun?: 'onBuildOnly' | 'always';
validate?: (config: Config, diagnostics: Diagnostic[]) => void;
generator: (config: Config, compilerCtx: CompilerCtx, buildCtx: BuildCtx, docs: JsonDocs) => Promise<void>;
copy?: CopyTask[];
Expand Down

0 comments on commit 055139c

Please sign in to comment.