Monday, 3 April 2017

What is the difference between linking stylesheets and requiring them in Webpack + VueJs?

Using the VueJs and Webpack combo I have figured out that to include external stylesheets (for example bootstrap) you can do one of two things:

In your main js script you could require the stylesheet like this:

require('./assets/lib/bootstrap.min.css');

Or you could simply move it to a static folder accessed via Express and link it in your main html file:

<link rel="stylesheet" type="text/css" href="/static/css/lib/bootstrap.min.css">

What is the difference between these two approaches? I don't quite see the advantage of using require over a link (unless that works locally per component I guess?). Are there any advantages in using one over the other?



via PeterTheLobster

No comments:

Post a Comment