K
K
kr_ilya2019-05-30 14:25:38
css
kr_ilya, 2019-05-30 14:25:38

How to load only the styles you need?

I don’t know which tags to choose, correct them if anything))
I’m making an ssr application on nuxt.js (vue.js) and ran into such a problem that absolutely all styles get into the source code of the page (I don’t take into account those in the components). These are all sorts of vuetify, mdi-icons and others. In total, 22k lines are obtained, which is not good.
Is it possible somehow not to load the entire style file, but only the necessary ones. (I do not need all the icons, but only a couple of pieces). Are there plugins that do this? Or do I need to write something in the webpack or nuxt.js config? How to solve the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2019-05-30
@Fragster

For js, you need to use the features of tree shaking from webpack, read here: https://vuetifyjs.com/en/framework/a-la-carte and in other similar sections on the libraries used.
For css, you can cut out unnecessary styles using https://www.purgecss.com/ but there are also nuances there, for example https://medium.com/@kyis/vue-tailwind-purgecss-the... for tailwind + vue , in general, you need to test and check extractors

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question