javascripttypescriptstenciljsstencil-componentstencil-compiler

stencil config copy - 'copy' does not exist in type 'StencilConfig'


How can I use 'copy' in stencil config, I am trying to make all i18n.json be available after compilation.

export const config: Config = {
  namespace: 'components',
  plugins: [
    ...
  ],
  outputTargets: [
    ...
  ],
  copy: [
    {
      src: "**/*.i18n.*.json",
      dest: "i18n",
      warn: true
    }
  ],
};

Error:

copy: { src: string; dest: string; warn: boolean; }[]; }' is not assignable to type 'StencilConfig'


Solution

  • Copy tasks have been moved into the output targets (I think in version 1). So simply move the copy task into one (or more) of your output targets.

    export const config: Config = {
      namespace: 'components',
      plugins: [
        ...
      ],
      outputTargets: [
        {
          type: 'www',
          copy: [
            {
              src: "**/*.i18n.*.json",
              dest: "i18n",
              warn: true
            }
          ],
        }
      ],
    };
    

    Here are the docs: https://stenciljs.com/docs/copy-tasks#copy-tasks-for-output-targets