How to parse CSS files?
amanjaggaPracto opened this issue · 2 comments
amanjaggaPracto commented
MatthewKosloski commented
I think you need to create a custom webpack.config.js
file. Try this out:
App.js:
import React, { Fragment } from 'react';
import css from './style.css';
export default () => (
<Fragment>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Embedded CSS with x0</title>
<style dangerouslySetInnerHTML={{__html: css}}></style>
<h1>Hello</h1>
<p>Hello world!</p>
</Fragment>
);
style.css:
body {
background: #ccc;
}
Install css-loader
via NPM and add a rule to a partial webpack.config.js
file.
npm install css-loader --save
webpack.config.js:
module.exports = {
module: {
rules: [
{test: /\.css$/, use: ['css-loader']}
]
}
}
Make sure to include the --config
flag in your NPM script:
--config webpack.config.js
johno commented
As @MatthewKosloski states, you need a custom webpack to achieve this. In v5 we will now automatically pick up a webpack.config.js and merge it with x0's defaults.