Comments (15)
@amerllica The isomorphic-style-loader
can be one of the option. However I will find a way to eliminate the hook.js
after migrating webpack to v6. Let's keep this issue for enhancement.
from react-cool-starter.
For tailwind, as my experience it's easy to be integrated with this starter by following its documentation (see this issue). If you have any problem, please let me know, I'm glad to help you.
For isopmorphic-style-loader
, I think we're on the same page.
from react-cool-starter.
@wellyshen No rush. In the end I went with next.js as it offers a lot of stuff that this framework has.
I still think your framework is cool, but I spent too many days fighting it to get tailwind to work and I needed a solution that just works.
from react-cool-starter.
Sorry for that. Next.js is an encapsulated framework, it's really easy to use, great choice. However this starter more like a scaffolding for DIY users. Thank you for your feedback, I'll spend time to make this starter more easy to use. Keep enrich the ecosystem of React.js.
BTW, I also using Next.js for some of my projects, we can still discuss about it lol.
from react-cool-starter.
Thank you for all your work @wellyshen - I understand not everyone has free time to work on their projects and it's a miracle that you've continued to update it for so long.
from react-cool-starter.
@amerllica The react-cool-form
. It's under developing.
from react-cool-starter.
@amerllica Regarding to your question:
hook.js
: a module for settingcss-modules-require-hook
andasset-require-hook
. We can omit it once we have implemented server-side bundling for development and production.css-modules-require-hook
: compiling css modules in runtime, so styles can work properly in SSR.asset-require-hook
: handling the import of static files in runtime, so images can work properly in SSR.postcss
configuration: I follow the setup document I think most people are following this way, however you can set it via webpack as well.
from react-cool-starter.
Dear @wellyshen bro, I set it by using Webpack and everything became ok now. for this sentence:
We can omit it once we have implemented server-side bundling for development and production.
When we will going to have a server build, we could use the isomorphic-style-loader
. I use it in this example. I know you are busy now. but when you have time. take a little glance at this example on the repo that I have in my mind.
I implemented this we have now in our minds to have in react-cool-starter
last year. if you have a little glance at it maybe it could be inspiring to us. I used webpack-hot-server-middleware
so the setting of Webpack should be an array. one for client one for the server.
from react-cool-starter.
is there a guide on how to make tailwind work with the current setup?
also what I don't like about isopmorphic-style-loader
is that it writes the CSS directly onto the page, compared to the current approach where it references the appropriate stylesheet
from react-cool-starter.
@wellyshen Thanks for responding.
The issue you posted unfortunately has broken links. Is there a quick patch that I could apply to grasp what's required?
I also experimented with removing css-modules-require-hook
entirely, but it seems the JS / html loads first before the CSS when I do it, causing a jarring re-render of unstyled to styled. I also noticed that you said you cannot do styles in SSR by removing the hook.
I still haven't figured out how the require hook prevents this from happening, but I understand that because it implements require.extensions
, it's impossible to implement a solution to use tailwind
with the require hook as it's an async plugin and require.extensions
is sync by its nature.
I'm looking into just using babel-loader with a combo of plugins to see if that might resolve things, but also wanted to ask you if you had a high-level idea of what you would have done in place of css-modules-require-hook
, so I can try the ideas out on my side.
from react-cool-starter.
I think I better understand the behavior now for why removing css-modules-require-hook
causes the CSS rendering issue.
When node.js encounters the import './test.css'
line, it looks at require.extensions
for the css
definition, which is filled in by css-modules-require-hook
.
As you stated above, css-modules-require-hook
is using postcss
to compile the style into a JS object to be consumed by the application directly. Having this hook allows immediate render of the server side HTML and style at the same time (I'm guessing the CSS is in the JS bundle at this point), whereas the stylesheets in the head
tags are loaded async to the static content (most likely for client-based navigation when you go forward and return to the original page to save on an SSR trip).
I looked into babel
as a potential alternative, but it ends up using pirates
which is a standardized way to hook into request.extensions
, which wouldn't work out since the node API is sync-only.
It really seems the only alternative is to render the CSS directly into the DOM since you'd be able to call the processors in an async fashion.
For more info which talks about postcss
sync / async issues:
https://medium.com/@longho/the-postcss-ecosystem-issue-b549c47b1a9
from react-cool-starter.
- For the tailwind: Sorry, I removed the example branch, I'll find time to show you again.
- For the hook: I will find a better solution for it when I migrate this starter to Webpack v5.
from react-cool-starter.
@wellyshen, The Webpack v5 is officially released, by:
@amerllica The isomorphic-style-loader can be one of the option. However I will find a way to eliminate the hook.js after migrating webpack to v6. Let's keep this issue for enhancement.
Do you have a plan to eliminate hook.js
?
from react-cool-starter.
@amerllica Yea, I'm planing to eliminate the hook.js
. It causes several limitations of postCSS plugins, but I might not do it soon, because I'm focusing on a new form library.
from react-cool-starter.
@wellyshen, which form library? could you say that name?
from react-cool-starter.
Related Issues (20)
- Is it possible to have cache for some request from node side? HOT 1
- Do we have server built file? HOT 3
- Cannot find module '~/node_modules/babel-loader/lib/index.js' when run build! HOT 5
- How you deal with react-refresh? HOT 13
- Internationalization BuiltIn (react-i18n-next)
- Release to npm as a template for CRA
- Not loading images on fresh open HOT 1
- Migration to React 18 HOT 1
- Update git ignore file
- Having lighter bundle alongside catching libraries in separated bundle file(s). HOT 7
- Page Getting Refresh When I Navigate from Home to User (Router Issue) HOT 2
- Is it possible to have more readable package.json file? HOT 10
- how to deploy node js application using pm2 config HOT 2
- Having faster development area for babel. HOT 2
- Client side loading doesn't work HOT 2
- Error: pngquant failed to build, make sure that libpng-dev is installed HOT 1
- css lib is not working - semantic ui HOT 3
- React-refresh throws error when use .js extension for page component HOT 1
- Cannot load images with more than 10Kb HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-cool-starter.