How do I add a Google Font to a VueJS Component?

前端 未结 7 2079
离开以前
离开以前 2021-02-03 20:42

I\'ve been trying for an hour to find a way to import a Google Font into a VueJS Component, but I cannot seem to find a solution, nothing worked yet, not even the stuff from pre

7条回答
  •  自闭症患者
    2021-02-03 21:16

    I would like to add to the answer given by msqar. If you are going to use Google Fonts Webpack Plugin: (https://www.npmjs.com/package/google-fonts-webpack-plugin ) and you are using the Vue CLI, you can add a vue.config.js file inside the root of your project. See Vue CLI docs: (https://cli.vuejs.org/guide/webpack.html#simple-configuration)

    Then add the code to that file:

     const GoogleFontsPlugin = require("google-fonts-webpack-plugin");
    
     module.exports = {
        chainWebpack: config => {
            plugins: [
                new GoogleFontsPlugin({
                    fonts: [
                        { family: "Source Sans Pro" }
                    ]
                })
            ]
         }
     }
    

提交回复
热议问题