ionic-team / stencil

A toolchain for building scalable, enterprise-ready component systems on top of TypeScript and Web Component standards. Stencil components can be distributed natively to React, Angular, Vue, and traditional web developers from a single, framework-agnostic codebase.
https://stenciljs.com
Other
12.41k stars 777 forks source link

"excludeSrc" config option not working #1843

Closed lufego closed 2 years ago

lufego commented 4 years ago

Stencil version:

 @stencil/core@^1.3.0

I'm submitting a:

[x] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior: Story file is inserted in the final dist collection folder

Expected behavior: Prevent the story file that goes in the same directory as my component from being inserted in the final collection dist folder

Steps to reproduce: I have the following structure:

stencil  
│
└───dist
│   └───collection
│       └───components
│           └───image-container
│                 image-container.css
│                 image-container.js
│                 image-container.stories.js //this file shouldn't be here
│   
└───src
    └───components
        └───image-container
              image-container.css
              image-container.tsx
              image-container.stories.js // this file is located here

Related code: In my stencil.config.js I have:

export const config: Config = {
  namespace: 'stencil',
  plugins: [
    postcss({
      plugins: [
        postcssCustomProperties({preserve: false}),
      ],
    })
  ],
  excludeSrc: ['**/*.stories.*'],
  outputTargets: [
    {
      type: 'dist',
      esmLoaderPath: '../loader',
    },
    {
      type: 'docs-readme'
    },
    {
      type: 'www',
      serviceWorker: null, // disable service workers
    }
  ]
};

but it still copies the file.

eduardoPinto12 commented 4 years ago

I'm having the exact same problem and even tried the suggestion on

Docs excludeSrc wrong regex

and wrote my-component-name/**. Does anyone know what the problem is?

Gomah commented 4 years ago

@lufego I have a similar config & it works for me, weird.

jesseer9 commented 4 years ago

I'm encountering the same issue. If I were to put all my stories under one folder, no nested sub-directories, then it works. Also using glob pattern excludeSrc: ['*/.stories.*']

Jessee

LeeBurton commented 4 years ago

"excludeSrc" is deprecated, it seems, and should be replaced by "exclude".

Poimen commented 3 years ago

In case someone else trips over this issue, you can fix this in the tsconfig.json by adding to the exclude patterns:

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "allowUnreachableCode": false,
    "declaration": false,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2017"
    ],
    "moduleResolution": "node",
    "module": "esnext",
    "target": "es2017",
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "jsx": "react",
    "jsxFactory": "h"
  },
  "include": [
    "src"
  ],
  "exclude": [
    "node_modules",
    "**/stories"
  ]
}
ionitron-bot[bot] commented 2 years ago

Thanks for the issue! This issue appears to be a support request. We use this issue tracker exclusively for bug reports and feature requests. Please use our slack channel for questions about Stencil.

Thank you for using Stencil!