question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hotloading imported css styles

See original GitHub issue

At the moment it seems that the post-css loader combined with ReactHotLoader and the postcss-import plugin does not auto-reload any stylesheets that get imported in a main css file.

I’ve created an example case in the following repo: https://github.com/0nn0/hotloader-postcss-imports/tree/postcss-import-plugin

You can produce the problem using the following steps.

  1. Check out Branch postcss-import-plugin
  2. Run npm install
  3. Run npm run start
  4. Open http://localhost:3000/
  5. Change background-color in styles.css (change will be directly visible)
  6. Change background-color in component.css (change will NOT be visible until you restart the app)

Is there a way that this can be solved?

@MoOx offered a suggestion here that the postcss-loader perhaps can make use of onImport like here if postcss-import is detected?

https://github.com/postcss/postcss-import/issues/40

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:36 (17 by maintainers)

github_iconTop GitHub Comments

32reactions
mummybotcommented, Feb 12, 2016

For those new to Webpack and coming to this thread and going “wah?!?” the exact code is:

    //webpack.config.js
    var postcssImport = require('postcss-import');
    ...
    postcss: function(webpack) {
        return [
            postcssImport({ addDependencyTo: webpack }), // Must be first item in list
            precss,
            autoprefixer
        ];
    },

Hopefully precss will support this soon, so we won’t need to use the postcss-import plugin as well.

3reactions
ZeeCodercommented, Aug 30, 2016
Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack 3 + PostCSS does not hotloading when changed ...
And I'm using Webpack 3, the hotloading feature doesn't work if I touch a css file that is an @import, people suggesed me...
Read more >
import - CSS: Cascading Style Sheets - MDN Web Docs
The @import CSS at-rule is used to import style rules from other valid stylesheets. An @import rule must be defined at the top...
Read more >
Css changes are lost whenever I hot reload(using parcel) my ...
Problem: Whenever I'm making changes in my sass file and hot reloading that sass file using parcel. Instantly, I can see the changes...
Read more >
Adam Wathan on Twitter: "@jeffscottward @tailwindcss ...
Getting the css injected anywhere to even start using it. Yes I did. It would seem straightforward but didn't work. And which way...
Read more >
Difference between Hot Reloading and Live ... - GeeksforGeeks
Hot reloading and Live reloading are something that Reacts Native ... import { Button, StyleSheet, View, Text } from "react-native" ;.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found