Marcelo Henrique
Marcelo Henrique

Reputation: 98

Is there a practical way of adding Webpack's generated stylesheets in Production

I'm building a normal App (JQuery, ES6, etc) with webpack and it's usual loaders. I came across the following situation:

The problem is, when I am in production I will need to add a <link href="some-bundle.css" /> to my index.html. OK. But by doing this, back in development I would get a 404 every time, since my css is not coming from any external source (It comes from JS and it's inline thing). And if I don't add the link tag, i'm never getting the compiled stylesheet.

So, how do you do this? Is there any loader to auto add the <link> in production? Or you just manually add It later on?

Thanks, []s

Upvotes: 1

Views: 91

Answers (1)

m1kael
m1kael

Reputation: 2851

You could use HTML Webpack Plugin to generate index.html files based on your Webpack build (dev/prod). One would include the link tag, another would not.

Upvotes: 1

Related Questions