score:5
I'm not sure what problem you have but I just followed the docs example:
1 Installed next-css npm install --save @zeit/next-css
2 Created next.config.js
const withCSS = require('@zeit/next-css');
module.exports = withCSS();
3 Created style.css
file in the root folder
.example {
font-size: 50px;
background-color: red;
}
4 Created a test page that includes styles
import '../style.css';
export default () => <div className="example">Hello World!</div>;
and the result shows this
I have the following dependencies
"@zeit/next-css": "^1.0.1",
"next": "^7.0.0",
"react": "^16.5.2",
"react-dom": "^16.5.2"
Hope this helps you a bit!
score:7
Try this in your next.config.js:
// next.config.js
const withCSS = require('@zeit/next-css')
module.exports = withCSS({
cssLoaderOptions: {
url: false
}
})
Now you should be able to import styleshets from node_modules like this:
import 'bootstrap-css-only/css/bootstrap.min.css';
Note: Using Next v 8+
Background: I spent a few hours trying to simply import a CSS installed as a node_module and the various solutions are mostly hacky workarounds, but as shown above, there is a simple solution. It was provided by one of the core team members: https://spectrum.chat/next-js/general/ignoring-folders-files-specifically-fonts~4f68cfd5-d576-46b8-adc8-86e9d7ea0b1f
score:19
I solved the problem. In my next.config.js
i use multiple plugins. My mistake was that I had written several module.exports
statements. In my case, the solution looks like this:
//next.config.js
const withImages = require('next-images');
const withCSS = require('@zeit/next-css');
module.exports = withImages(withCSS());
Source: stackoverflow.com
Related Query
- React with NextJS and Next-CSS: You may need an appropriate loader to handle this file type
- You may need an appropriate loader to handle this file type - Angular 4 with React
- React - Module parse failed: Unexpected Token. You may need an appropriate loader to handle this file type
- CSS - You may need an appropriate loader to handle this file type
- CSS ReactJs - You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file
- React / Webpack - "Module parse failed: Unexpected token - You may need an appropriate loader to handle this file type."
- webpack4: React babel - You may need an appropriate loader to handle this file type
- You may need an appropriate loader to handle this file type: arrow function in react component
- “You may need an appropriate loader to handle this file type” with Webpack and Babel
- React : You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file(Local Node module)
- React babel loader - you may need an appropriate loader to handle this file type
- You may need an appropriate loader to handle this file type. React & Material UI
- Webpack 4.6.0 loading css file: You may need an appropriate loader to handle this file type
- You may need an appropriate loader to handle this file type, loading image in react
- Webpack 2 : You may need an appropriate loader to handle this file type React
- React import html - Module parse failed: You may need an appropriate loader to handle this file type
- You may need an appropriate loader to handle this file type with babel/webpack2/react
- You may need an appropriate loader to handle this file type. with webpack
- React webpack error: You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file
- React Failed to compile error: Module parse failed: Unexpected token. You may need an appropriate loader to handle this file type
- You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file."
- IMAGE: You may need an appropriate loader to handle this file type
- how to solve this error You may need an appropriate loader to handle this file type
- Unable to run webpack-dev-server on react-native-web. ERROR: You may need an appropriate loader to handle this file type
- Module parse failed: Unexpected token (7:5) You may need an appropriate loader to handle this file type
- Module parse failed: Unexpected character '�' (1:0) You may need an appropriate loader to handle this file type
- Error: You may need an appropriate loader to handle this file type
- Babel Webpack Error: You may need an appropriate loader to handle this file type
- ReactJS error You may need an appropriate loader to handle this file type
- Click to open PDF - You may need an appropriate loader to handle this file type
More Query from same tag
- Numbering child elements in ReactJS
- React is rendering [Object object] instead of JSX elements inside the array
- React: REST redirect failing
- Getting a crashloopbackoff error in Google Kubernetes Engine
- How to stop the page from refreshing and from loosing the users input on an unssucceful post request
- How to display three post photo div at the bottom of the page using Reactjs and Css
- Isolate specific config files from main bundle
- Accessible nested button inside button?
- How To Render Multiple 3D of Same 3D Model;
- Upload multiple images to firebase then save image url to firestore
- Calling dynamic component in React JS
- How to make images fit the page in React/Bootstrap?
- Avoid not needed requests on Saga
- react-router-dom does not display component
- How to convert raw PDF to PDF Document
- Redux: Dynamically pass component to Provider
- Fetching data from Firebase with react
- when I click on the icon, It was not redirected to the link. How can I do that?
- Why is my React component that keeps track of state history not visually rendering?
- Material UI – Global checkbox focus styling (not locally)
- React Bootstrap on mobile: confusing focus styling
- conditionally render child component following onChange event
- password check without using regex in reactjs
- Make animate execute again after svg path changes
- useEffect not triggering but the template is being rendered somehow
- Fork and Pull React-Router
- Textfield's label gets clipped when inside a Dialog
- Meteor-react passing variable to child container
- React Splitting strings in an array
- How to remove null values from props.map