Comments (11)
@shoebmogal Here's how I've done it.
I installed the following packages:
extract-text-webpack-plugin
css-loader
sass-loader
style-loader
Here's an example of my webpack.config.dev.js
https://gist.github.com/rowellx68/362ceaeedf09c83c2b9c
You should then add this line in the server.js
<link rel="stylesheet" href="${ isDeveloping ? '/build/static/main.css' : assets.main.css}">
Then in the App component
if (typeof window !== 'undefined') {
require('../css/core.scss');
require('../css/theme.scss');
}
We need to wrap requiring the scss
files so we don't get a syntax error when we start the server.
from razzle.
The issue seems to stem from you requiring flexboxgrid
directly inside Grid.js. After trying it out myself, what you could do is @import
flexboxgrid
in your own css instead.
I have this in my webpack.config
resolve: {
modulesDirectories: [ 'node_modules' ]
}
More info about
resolve.moduleDirectories
--> here
Then inside my own css
file I just imported it as below:
@import "~flexboxgrid/dist/flexboxgrid";
And here's the module loader for my css
and scss
{
test: /\.(s?css)$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader!sass-loader")
}
Of course you will require the correct loaders and plugin for it to work. 😄
from razzle.
Are you just looking for plain CSS or SASS as well?
from razzle.
Just extract your css to build/static
folder and include the link to the extracted css file the same way the js files are referenced in server.js
. Remove aphrodite, etc.
from razzle.
@rowellx68 yes I am trying to use extensions which use CSS and SASS.
@jaredpalmer I ll try that. But an example would be helpful. I tried to use css-loader , sass loader and give the directory in "includes" of the webpack config. Doesnt help
from razzle.
I ll give it a try @rowellx68 ! Thanks for all the help, will respond with my results and close thid issue.
from razzle.
Hi @rowellx68 , I tried doing all of that didnt work :(
Here's the error:
/Users/../react-production-starter/node_modules/flexboxgrid/dist/flexboxgrid.css:1
(function (exports, require, module, __filename, __dirname) { .container-fluid,
^
SyntaxError: Unexpected token .
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:404:25)
at Module._extensions..js (module.js:432:10)
at Object.require.extensions.(anonymous function) as .js
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object. (..../react-production-starter/node_modules/react-flexbox-grid/lib/components/Grid.js:13:20)
at Module._compile (module.js:425:26)
from razzle.
Thanks for the response @rowellx68 but its an external module that I am importing.
Infact any model that has css in it is failing with similar error.
from razzle.
@shoebmogal You'll need style-loader
and css-loader
to support plain css, even in external modules.
from razzle.
I am closing this issue and opening a PR for a recipes folder.
from razzle.
@shoebmogal do you solved your problem ?
I've same problem . And I do not know what is the solution ?
@shoebmogal @rowellx68 I opened a issue(532) about this. Thanks if you know the solution and answer that.
from razzle.
Related Issues (20)
- HMR does not activate when a file containing only types is modified
- Dependency Terminate uses GPLv2 License - any alternative?
- Can't deploy to heroku
- plugin options are coming to be undefined HOT 4
- Content Security Policy Implementation HOT 1
- Regarding deployment in server HOT 5
- For Laravel project, add it where ? please HOT 1
- Is the project abandoned? 🤔 HOT 8
- How to expose config to out ?
- digital envelope routines::unsupported HOT 1
- Why razzle forcing buffer and process package in ProvidePlugin if webpack version is 5
- Unexpected token: punc (.) HOT 6
- Does latest razzle support react 18 ? HOT 1
- Support for react 18 HOT 4
- ~Wrong repo~
- How to use webpack 5 with Razzle 4 HOT 1
- Razzle utilizes vulnerable versions of browserslist and minimatch as nested dependencies, causing security issues.
- Maybe mark this project as abandoned in its github repository description and in readme? HOT 2
- Anyone has a fork updated for webpack-dev-server 5? HOT 1
- How to use 'mini-css-extract-plugin' in razzle config HOT 1
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 razzle.