question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

styleguidist:build removes some HTML classes that are required for styling

See original GitHub issue

Current behavior

Styleguide works great locally when spinning up the development server, but I notice that when I run styleguidist:build some of the HTML classes that are generated by styleguidist are not added to the final build resulting in some elements unstyled like the h1 of the Logo and the Prism.js code highlighting.

Development build

(class rsg--logo-49 exists on the h1 element) image

(rsg--jssEditor-61 class and other classes exist to style the code example syntax highlighting) image

Production Build

(class missing from h1) image

(classes seem missing and code example is unstyled) image

This is my styleguide.config.js

const config = {
  theme: {
    fontFamily: {
      base: '"Matter", sans-serif',
    },
    color: {
      base: '#544742',
      sidebarBackground: '#fffbf7',
      link: '#D14010',
      linkHover: '#d14010bf',
    },
    sidebarWidth: 300,
    borderRadius: 0,
  },
  styleguideDir: '../../public/styleguide',
  // Code below can split page into sections
  // Note you will need more than one section to show the section name in the sidebar
  sections: [
    {
      name: 'Layout',
      components: 'src/js/v3/Components/layout/*.vue',
    },
    {
        name: 'Inputs',
        components: 'src/js/v3/Components/utils/inputs/*.vue',
    },
    {
      name: 'Cards',
      components: 'src/js/v3/Components/cards/*.vue',
    },
    {
      name: 'Notifications/Errors',
      components: 'src/js/v3/Components/notifications/*.vue',
    },
    {
      name: 'Lists',
      components: 'src/js/v3/Components/lists/*.vue',
    },
  ],
  title: 'Felix Component Guide',
  components: ['src/js/v3/Account/Components/*.vue', 'src/js/v3/Components/**/**/*.vue'],
  webpackConfig: Object.assign({}, require('./webpack.config.js')),
  copyCodeButton: true,
  skipComponentsWithoutExample: true,
  // Any assets you want to use need to be imported here and need appropriate webpack loaders 
  // Eventually this should be a separate file(s) or array of included assets
  require: [
    path.join(__dirname, './src/scss/app.scss'),
    path.join(__dirname, '/assets/fonts/Matter-Regular.woff'),
    path.join(__dirname, '/assets/fonts/Matter-Bold.woff'),
    path.join(__dirname, '/assets/img/new/back arrow.svg'),
  ],
};

// Add additionnal font loader for font files
config.webpackConfig.module.rules.push({
  test: /\.(woff(2)?|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,
  use: [
    {
      loader: 'file-loader',
      options: {
        name: '[name].[ext]',
        outputPath: 'themes/pillbox/assets/fonts/',
      },
    },
  ],
});

config.webpackConfig.module.rules.push({
  test: /\.(png|jpe?g|gif|svg)$/i,
  use: [
    {
      loader: 'file-loader',
      options: {
        name: '[name].[ext]',
        outputPath: 'themes/pillbox/assets/img/new/',
      },
    },
  ],
});


module.exports = config;

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
elevatebartcommented, Sep 14, 2020

I tried to reproduce this issue without success. It is very probably due to the webpack configuration that styleguidist is using.

What framework/library/rendering tool are you using to build and render your library?

Nuxt? Quasar?

It could as well be a 3rd party webpack plugin like purge-css that removes all the “unused” classes in production. If it’s the case, remove this plugin from your webpack config, for styleguidist, and everything should return to normal.

0reactions
Eternal-Risecommented, Dec 17, 2021

setting minimaze: false in styleguide.config.js fixed issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cookbook - React Styleguidist
How to hide some components in style guide but make them available in ... As React removes all PropTypes in its production build,...
Read more >
Change Styleguides output | Vue Styleguidist
Change Styleguides output. This page is meant to show how to customize a styleguide. It will get you to transform any part of...
Read more >
styleguidist/styleguidist - Gitter
(specifically space which is exported from src/client/styles/theme.js ) ... Second question, how could I use propsParser option to ignore all classes props ...
Read more >
vue-styleguidist | Yarn - Package Manager
... use webpack version to only remove when necessary (cdd8c84); try creating a release using lerna version (db9de67); use continue-on-error (5884599) ...
Read more >
org.eclipse.opencert.elastic.app
You almost never need to update create-react-app itself: it delegates all the setup ... Button.css'; // Tell Webpack that Button.js uses these styles...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found