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.

Styles are not applied on Webpack5

See original GitHub issue

Hello guys, I am using Draftjs mention plugin and I am getting the result below Screenshot from 2021-02-24 00-04-16

This is my webpack5 code:

    module: {
      rules: [
        {
          test: /\.css$/,
          use: ['style-loader', 'css-loader'],
        },
      ],
    },

And this is my code

import React, { ReactElement, useRef, useState } from 'react';
import { EditorState } from 'draft-js';
import Editor from '@draft-js-plugins/editor';
import createMentionPlugin, {
  defaultSuggestionsFilter,
} from '@draft-js-plugins/mention';
import editorStyles from './editorStyles.css';
import mentions from './Mention';
import '@draft-js-plugins/mention/lib/plugin.css';

const mentionPlugin = createMentionPlugin();
const { MentionSuggestions } = mentionPlugin;
const plugins = [mentionPlugin];

const SimpleMentionEditor = (): ReactElement => {
  const [editorState, setEditorState] = useState(EditorState.createEmpty());
  const editor = useRef<Editor>();

  const [open, setOpen] = useState(false);
  const [search, setSearch] = useState('');

  const onChange = (value): void => {
    setEditorState(value);
  };

  const focus = (): void => {
    editor.current.focus();
  };

  const onOpenChange = (newOpen): void => {
    setOpen(newOpen);
  };

  const onSearchChange = ({ value }): void => {
    setSearch(value);
  };

  const onAddMention = (): void => {
    // get the mention object selected
  };

  return (
    <div className={editorStyles.editor} onClick={focus}>
      <Editor
        editorState={editorState}
        onChange={onChange}
        plugins={plugins}
        ref={(element) => {
          editor.current = element;
        }}
      />
      <MentionSuggestions
        open={open}
        suggestions={defaultSuggestionsFilter(search, mentions)}
        onOpenChange={onOpenChange}
        onSearchChange={onSearchChange}
        onAddMention={onAddMention}
      />
    </div>
  );
};

export default SimpleMentionEditor;

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:24 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
DiFukscommented, Jun 9, 2021

Can you try to change the sideEffects option in the @draft-js-plugins/* packages to

"sideEffects": [
  "*.css"
]

If this solves the issue I will replace them here.

After changing to

"sideEffects": [
   "*.css"
] 

in @ draft-js-plugins /**/ package.json everything works fine

0reactions
fxOnecommented, Jun 9, 2021

Can you try to change the sideEffects option in the @draft-js-plugins/* packages to

"sideEffects": [
  "*.css"
]

If this solves the issue I will replace them here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Webpack - CSS not applied - Stack Overflow
The problem is that CSS in not being applied the elements on the page (it is present in the built file). This is...
Read more >
style-loader - webpack
Disclaimer: style-loader is a third-party package maintained by community members, it potentially does not have the same support, security policy or license ...
Read more >
Loading Styles - SurviveJS
Webpack doesn't handle styling out of the box, and you will have to use ... Loaders return the new source files with transformations...
Read more >
How to configure CSS Modules for webpack - LogRocket Blog
In the following code block, css-loader and style-loader are used together. Similar to babel-loader , we can load CSS files to style our...
Read more >
Client side extension imported css via webpack css loader is ...
js”, however, they are somehow not applied. I have the impression that aui are somehow overriding these. My CSS styling approach is the ......
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