Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
django webpack loader setting to load css

It works when I set up like below. I am using django-webpack-loader

index.html

{% load render_bundle from webpack_loader %}
<!DOCTYPE html>

<html>
    <head>
        <meta charset="UTF-8">
        <title>Jayground</title>
        {% render_bundle 'main' 'css' %}
    </head>

    <body>
        <div id="react-app"></div>
        {% render_bundle 'main' 'js' %}
    </body>
</html>

Header.js

import styles from './header.css';

export default class Header extends React.Component {
    render(){
        <div className="header">
            hello
        </div>
    }
}

webpack.config.js (I made styles.css separately and then load css file in html separately so that className="header" works.)

config.plugins = config.plugins.concat([
    new ExtractTextPlugin('styles.css'),
]);

config.module.rules.push(
    {
        test: /\.css$/,
        use: ExtractTextPlugin.extract({
            use: 'css-loader'
        })
    }
)

According to what I understood, code below should work too. If I don't separate css file by using ExtractTextWebpackPlugin, bundle js file have css information in it like this.

exports.push([module.i, ".header {\r\n  background-color: blue;\r\n}\r\n\r\n.extra {\r\n\tfont-size: 50;\r\n}", ""]);

css should be loaded properly.

Header.js

import styles from './header.css';

export default class Header extends React.Component {
    render(){
        <div className={styles.header}>
            hello
        </div>
    }
}

webpack.config.js

config.module.rules.push(
    {
        test: /\.css$/,
        use: ['style-loader', 'css-loader']
    }
)

Do I miss something to work properly?

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!