Skip to content
This repository has been archived by the owner on Jan 26, 2020. It is now read-only.

import style.css/scss in App.js? #66

Closed
muhrusdi opened this issue Jul 24, 2018 · 9 comments
Closed

import style.css/scss in App.js? #66

muhrusdi opened this issue Jul 24, 2018 · 9 comments
Labels
enhancement New feature or request

Comments

@muhrusdi
Copy link

can i import style.css/scss in App.js file?

@alidcast
Copy link
Owner

Are you using Razzle?

I haven't tried this personally (I use css-in-js) but I don't see why it wouldn't work since razzle does support this

does it not work when you try it?

@muhrusdi
Copy link
Author

its work in development, but not work in production, the file (bundle.xxx.css) is not loaded in browser.

screen shot 2018-07-24 at 12 05 03

@alidcast
Copy link
Owner

alidcast commented Jul 24, 2018

ahh yea there needs to be to a way to inject the assets tags

e.g.

const assets = require(process.env.RAZZLE_ASSETS_MANIFEST);

new Rogue(App, { headTags: [`<link rel="stylesheet" href=${assets.client.css} />`] })

something like this will need to be added

@alidcast alidcast added the enhancement New feature or request label Jul 24, 2018
@muhrusdi
Copy link
Author

undefined css in assets variable, just js.

screen shot 2018-07-24 at 14 08 19

and i add link tag in the file App.js, because there is no headTags in the rouge api
screen shot 2018-07-24 at 14 10 54

@alidcast
Copy link
Owner

yeah doing it via getInitialProps is a good temporary workaround

hmm is it undefined in production? just check if it exists first before setting it

also just remembered loadable-components (for code splitting) only supports css-in-js (gregberge/loadable-components#94), so now that Rogue is independent of build setup we might have to also support another library for doing this

@muhrusdi
Copy link
Author

thanks

@alidcast
Copy link
Owner

So to confirm, adding headTag works?

@muhrusdi
Copy link
Author

yes its work, the file css is loaded in prod , undfined in dev. but why this way does not work const rogue = new Rogue(App, { headTags: [${css}], bundleUrl: bundleUrl})

@alidcast
Copy link
Owner

alidcast commented Jul 25, 2018

opened another issue to remind myself to implement it soon

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants