Angular 发布包并在中使用后,模具全局样式未应用 //stencil.config.ts 从'@stencil/core'导入{Config}; 导出常量配置:配置={ 命名空间:“mycomponent”, 输出目标:[ { 类型:“dist” }, { 键入:“www”, 服务工作者:空 } ], globalStyle:'src/global/variables.css' } //src/global/variables.css :根{ --qa原色:#2169e7; --qa二次色:#fcd92b; --qa深色:#0000; --qa浅色:#ffff; --qa字体系列:Arial、Helvetica、无衬线字体; --qa字体大小:12px; } //index.html

Angular 发布包并在中使用后,模具全局样式未应用 //stencil.config.ts 从'@stencil/core'导入{Config}; 导出常量配置:配置={ 命名空间:“mycomponent”, 输出目标:[ { 类型:“dist” }, { 键入:“www”, 服务工作者:空 } ], globalStyle:'src/global/variables.css' } //src/global/variables.css :根{ --qa原色:#2169e7; --qa二次色:#fcd92b; --qa深色:#0000; --qa浅色:#ffff; --qa字体系列:Arial、Helvetica、无衬线字体; --qa字体大小:12px; } //index.html,angular,stenciljs,Angular,Stenciljs,在运行模具项目时,这对我来说很好,但一旦我将包发布到npm并以角度使用,这些样式就不会得到应用。请帮助该/build/.css文件用于www输出目标。当您发布到NPM时,发布的是dist输出目标。因此,您需要将文件引用为/dist/.css,即。E在这种情况下 href to/build是否仍然有效?它在我的模具项目中工作我不太明白。。。如果我只是将该添加到index.html文件中,那么我的项目找不到css文件。(例如,当我运行ng serve,http://localhost:4200/d

在运行模具项目时,这对我来说很好,但一旦我将包发布到npm并以角度使用,这些样式就不会得到应用。请帮助该
/build/.css
文件用于
www
输出目标。当您发布到NPM时,发布的是
dist
输出目标。因此,您需要将文件引用为
/dist/.css
,即。E在这种情况下



href to/build是否仍然有效?它在我的模具项目中工作我不太明白。。。如果我只是将该
添加到index.html文件中,那么我的项目找不到css文件。(例如,当我运行
ng serve
http://localhost:4200/dist/mycomponent/mycomponent.css找不到
。还有什么我需要配置的吗?值得一提的是-我确实在
/node\u modules/mycomponent/dist/mycomponent/mycomponent.css中看到了css文件
。它似乎没有达到我的要求项目
// stencil.config.ts
import { Config } from '@stencil/core';

export const config: Config = {
    namespace: 'mycomponent',
    outputTargets:[
        {
            type: 'dist'
        },
        {
            type: 'www',
            serviceWorker: null
        }
    ],
    globalStyle: 'src/global/variables.css'
}


// src/global/variables.css
:root {
    --qa-primary-color: #2169e7;
    --qa-secondary-color: #fcd92b;
    --qa-dark-color: #0000;
    --qa-light-color: #ffff;
    --qa-font-family: Arial, Helvetica, sans-serif;
    --qa-font-size: 12px;
}
// index.html
<link rel="stylesheet" href="/build/mycomponent.css">