Issue #2796Opened May 22, 2020by vinceumo2 reactions

CSS get removed when project init

Question

Hi,

I'm trying to import utility classes into grapes js. My issue is that grapes remove them if they are not use by an element in the canvas. I'm building a custom panel to link to my CSS variables (CSS custom properties) to manage this classes in grapes.

How can I import my CSS and keep all the classes?

I have created a small demo of my issue https://codesandbox.io/s/musing-moore-1tswh?file=/index.js

Go in index.html and you will see all the CSS. When clicking on view code, you will see most of the CSS have been removed.

Thanks a lot

Answers (3)

Ju99ernautMay 25, 20201 reactions

grapesJS does not deal with css directly it first parses it into a CSSOM and uses that in the editor so a class will not show up in the code preview unless there is a component in the editor canvas using it. Your classes will be imported dynamically as they are used in the editor canvas.

Ju99ernautMay 25, 20201 reactions

You could load the stylesheet externally during init and remove it from the index.html altogether

canvas:{
   styles: [
      'path/to/stylesheet'
   ]
}

You can also check the SelectorManager and CssComposer api reference

vinceumoMay 25, 20200 reactions

Thanks @Ju99ernaut, do you know if there is anyway to add some css and make it available in the canvas and as well have it in the export?

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.