我在构建样式指南“npx styleguidist build”时遇到了问题,但在运行“npx styleguidist server”时却没有。在 styleguidist build 生成的 css 文件中,字体链接与 build 文件夹中的内容不匹配:
src:url(static/media/GothamRounded-Light.a6caeaca.woff2)
如果我将css构建文件中的这个url替换为:
src:url(../media/GothamRounded-Light.a6caeaca.woff2)
查看构建文件夹的树:styleguidedist 构建文件夹的图片
styleguide.config.js :
const path = require('path')
const fs = require('fs');
module.exports = {
require: [
path.join(__dirname, 'src/assets/scss/app.scss'),
],
updateExample(props, exampleFilePath) {
const { settings, lang } = props
if (settings && typeof settings.file === 'string') {
const filepath = path.resolve(
path.dirname(exampleFilePath),
settings.file
)
const { file, ...restSettings } = settings
return {
content: fs.readFileSync(filepath, 'utf8'),
settings: restSettings,
lang
}
}
return props
},
sections: [
{
name: 'UI Components',
components: 'src/components/**/*.jsx',
exampleMode: 'collapse', // 'hide' | 'collapse' | 'expand'
usageMode: 'collapse', // 'hide' | 'collapse' | 'expand'
collapseCode: true,
}
],
}