-
-
Notifications
You must be signed in to change notification settings - Fork 873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Less #96
Comments
Hey so you'll need to add style-loader, extract-text-loader and then either write your own parser for webpack's json output, or use assets-webpack-plugin (I prefer that assets-webpack personally). Then you need to load assets.json in server/index.js and then use template literals to properly load the correct path to the compiles css file: Take a look at my repo restarter and it's webpack configs and |
Relevant lines from Restarter RepoInstead of .css, you'll want to change this out for .less. Depending on whether you want to use postcss or not, your loader query will differ: I also suggest adding a vanilla .css loader just for Only load assets.json (output of assets-webpack-plugin in production): Because webpack in production adds hashes to the end of the file names, you need to render the correct one: Note: It goes without saying that you'll need to remove all the Aphrodite code from 1. components, 2. server/index.js, 3. client/index.js Hope that helps. @justingreenberg Did I miss anything? |
Oh, thx u man for your quickly answer. But I want using less like:
and I want to write some code in index.js like:
In another projects without SSR, it's work, but in this implementation it's not work correctly. Maybe I should use a webpack-dev-server for this trick. At now, I have webpack config file for development mode with this lines:
And when I tried to run
It really huge issue for me :( I not see how I can fix it. Please help me if you can |
Oh, it's my fuckup. I forgot about my isomorphic code and how it's code running. So, I found solution for that, it's webpack-isomorphic-tools. Thx for your time. If I will have a time I would like to fork your boilerplant and configure for Less. |
No worries. Glad you figured things out. SSR definitely complicates things. TBH, I'm not even convinced it's worth it. Recently been building apps with "poor man's SSR": which basically loads up state into window.InitalState, but doesn't call ReactDOMServer.render cuz it's pretty slow and you still have to wait for React to load on the client for things to be interactive. This is how Instagram is rendering these days (just view source in chrome, and you'll find a react-div and a HUGE window.initialState). The beauty of this method is you can still block google from indexing your API routes with robots.txt, but get it render/SEO the client. Auth is super simple too, you just pass req.user (from passport etc) for each request into initialState. The other great thing about this, is that you don't have to worry about isomorphic webpack, which as you have just learned, can be a huge headache. However, if one day, you do decide that you want to render components on server, you'll only have to change a trivial amount of code. |
Hi.
How can I use Less for building my stylesheets? Because I don't want to use Aphrodite. Please, help me, because I started to use this boilerplate for the real project.
The text was updated successfully, but these errors were encountered: