title: Styles injection order with JSS and Material-UI differs between dev and prod
body: <p>I'm trying to use Material-UI (<a href="https://material-ui.com/" rel="nofollow noreferrer">https://material-ui.com/</a>) with NextJS (<a href="https://nextjs.org/" rel="nofollow noreferrer">https://nextjs.org/</a>), styling with the JSS solution.</p>
  
  <p><strong>It works well in my local environment, but my design is broken on prod</strong>. After a quick analysis, it seems to be an <strong>issue with the injection order</strong> of the <code>&lt;style&gt;</code> tag: my styles are indeed injecting between MUI ones, canceling my changes.</p>
  
  <p><strong>DEV ENVIRONMENT</strong><br>
  <a href="https://i.stack.imgur.com/yB8EJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yB8EJ.png" alt="In dev"></a></p>
  
  <p><strong>PROD ENVIRONMENT</strong><br>
  <a href="https://i.stack.imgur.com/5hoDR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5hoDR.png" alt="In prod"></a></p>
  
  <p>As you can see from the screenshots above, the injection order is different in prod. The <code>Alert</code> style is therefore overwritten by the <code>MuiButton</code> making my page broken.
  <em>(I also don't get why the styles for <code>Alert</code> and <code>DashboardLayout</code> have an empty clone, but that's not my main issue here...)</em></p>
  
  <p>It may be worth to note that the <strong>styles generated on the server-side are OK</strong>: the page is rendered correctly on loading. The issue occurs only after the client-side has run.</p>
  
  <p>My code is based on <a href="https://github.com/mui-org/material-ui/blob/master/examples/nextjs/" rel="nofollow noreferrer">this example from Material-UI (usage with NextJS)</a>.</p>
  
  <p>I really don't get why it's OK on dev and not on prod (and <strong>I don't manage with NextJS to run the prod build on local for an easier debugging ^^'</strong>).</p>
  
  <p>Do you have an idea on how to understand and investigate this issue?</p>
  
  <p>Thanks in advance :)</p>