I have a component App.js and a stylesheet App.css I'd like to load accordingly.
This is what I have:
// App.js
import React, { Component } from "react";
import { render } from "react-dom";
import './App.css';
import Header from "./Header";
import Body from "./Body";
import Footer from "./Footer";
export default class App extends Component {
constructor(props) {
super(props);
}
render() {
return (
<div className={'AppWrapper'}>
<Header />
<Body />
<Footer />
</div>
);
}
}
const appDiv = document.getElementById("app");
render(<App />, appDiv);
// App.css
.AppWrapper {
width: 100%;
}
// Webpack config
const path = require("path");
const webpack = require("webpack");
module.exports = {
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "./static/frontend"),
filename: "[name].js",
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
}, {
test: /\.css$/,
exclude: /node_modules/,
use: ["css-loader"],
},
],
},
optimization: {
minimize: true,
},
plugins: [
new webpack.DefinePlugin({
"process.env": {
// This has effect on the react lib size
NODE_ENV: JSON.stringify("development"),
},
}),
],
};
However, the css class isn't applied to the DOM when rendering the page. There are no errors/issues neither.
What do I miss?
