0

I am using the froala editor in meteor and react. The froala editor requires you to import css files. https://www.froala.com/wysiwyg-editor/docs/framework-plugins/react When i import for example

import 'froala-editor/css/froala_style.min.css';

The server crashes and gives me an error

SyntaxError: Unexpected token .

It seems to be parsing the file as javascript. I am using meteor version 1.5.2. What is the correct way to import css files from node modules in meteor 1.5.2?

3
  • It's perfectly legit to import css files in react however it looks like import doesn't expect a minified file type - i.e. it expects path/filename.type not path/filename.something.type Try importing the un-minified file, it will get minified later in the build anyway. Commented Sep 7, 2017 at 20:45
  • i imported import 'font-awesome/css/font-awesome.css'; for example and it gave me the same error @MichelFloyd Commented Sep 7, 2017 at 20:49
  • Then the path might be the problem - import paths are relative to the file they are in. This path assumes your js file is at root which is unlikely. Commented Sep 7, 2017 at 20:59

1 Answer 1

3

You can use the @import syntax in your main style sheet to import the css instead of doing it in the component.

Sign up to request clarification or add additional context in comments.

5 Comments

The froala editor requires me to import the CSS. In order to render the component properly, i have to import the CSS. froala.com/wysiwyg-editor/docs/framework-plugins/react
Yes, but you don't have to import the css in the same file. You just need to make sure that the css gets imported before the component renders. By importing it in your main style sheet, you are importing it in with the rest of your apps css so it will be loaded by the time your component renders.
but is there a solution to this problem of importing css files from node modules in meteor rather than hacks around it?
Yes, using @import in your stylesheet. It is not a hack lol sass-lang.com/guide

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.