stenciljs - StencilJS:编译 scss 并复制到 dist 文件夹
问题描述
我的目标是在分发包中提供一个 css 文件,如果需要,消费者可以使用它。
为此,我想创建一种全局 scss 文件,但我想避免这种样式附加到每个组件 + 它也不会被组件直接使用。因此,为此我想my-style.scss
在文件夹中的某处创建文件/src
。
编译这个文件my-style.css
并将其复制到dist
文件夹的最佳方法是什么?
解决方案
It is possible to specify a global style with Stencil. Simply add the globalStyle
property to your stencil.config.js
and provide the entry scss
file. Your config should look something like this:
const sass = require('@stencil/sass');
exports.config = {
namespace: 'my-component-lib',
outputTargets:[
{
type: 'dist'
},
{
type: 'www',
serviceWorker: false
}
],
globalStyle: 'src/globals/app.scss',
plugins: [
sass()
]
};
exports.devServer = {
root: 'www',
watchGlob: '**/**'
}
The build will successfully compile the scss to dist/my-component-lib.css
.
推荐阅读
- indexing - 在 Acumatica 中恢复快照会禁用某些索引
- android - 安卓。活动暂停或完成后如何停止活动中的所有侦听器?(无侦听器参考)
- c++ - 将字符串分配给类的实例(重载 = )?
- javascript - 通过 javascript 处理特定的图像响应
- html - HTML表格,标题是属性列标识符吗?
- python-2.7 - For 循环失败,但代码似乎是正确的
- bash - Bash 脚本案例无法正确评估条件
- google-chrome - Chrome 69.0.3497.100 中的 CORS 问题
- powershell - Powershell 脚本 - 使用 InterfaceDescription 更改 IP
- scala - 将列附加到 HDFS 中的现有 CSV 文件