Reactjs React styleguidedist,npx StyleGuidest构建不';在css中找不到导入的字体文件
我在构建styleguide“npx styleguidist build”时遇到了一个问题,而在运行“npx styleguidist server”时却没有这个问题。在styleguidist build生成的css文件中,指向字体的链接与build文件夹中的内容不匹配:Reactjs React styleguidedist,npx StyleGuidest构建不';在css中找不到导入的字体文件,reactjs,font-face,react-styleguidist,Reactjs,Font Face,React Styleguidist,我在构建styleguide“npx styleguidist build”时遇到了一个问题,而在运行“npx styleguidist server”时却没有这个问题。在styleguidist build生成的css文件中,指向字体的链接与build文件夹中的内容不匹配: src:url(static/media/GothamRounded-Light.a6caeaca.woff2) 如果我将css构建文件中的此url替换为: src:url(../media/GothamRounded-
src:url(static/media/GothamRounded-Light.a6caeaca.woff2)
如果我将css构建文件中的此url替换为:
src:url(../media/GothamRounded-Light.a6caeaca.woff2)
请参见生成文件夹的树:
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,
}
],
}