Search code examples
stenciljsstencil-compiler

StencilJS : Is it possible to set "globalStyle" on the stencil.config.ts file to a css from a node_module


Trying to set a global style css file on my stencil project. The only issue is that the specific css file I want to link is inside a node_module. I know I can import the css for each component but I was hoping to set it as a globalStyle.

Whenever I try to do it for some reason it gives me the following error

"The file {./node_modules/@styles/file.css}" was unable to load.


Solution

  • You can try using a copy task to bring that file from node_modules to your dist, and reference that css file in index.html

    if you are using www output target, copy task config can look like this

    outputTargets: [
        {
          type: 'www',
          dir: 'public',
          copy: [
            { src: '../node_modules/@styles/file.css', dest: 'assets/css' }
          ]
        }
      ]