VueJS-如何在不使用vue-fontawesome的情况下导入导入无fontawesome 5?

时间:2018-11-23 08:54:17

标签: symfony vue.js font-awesome-5

我正在将我的一个项目从AngularJS转换为VueJS。我试图弄清楚如何在不使用vue-fontawesome的情况下包括@ fortawesome / fontawesome-free。我觉得无需使用vue-fontawesome即可轻松添加图标(直接从其网站示例进行复制和粘贴)。

在将它导入到main.js中时遇到问题。这似乎不起作用:

#main.js    
import '@fortawesome/fontawesome-free/css/all.css';

所有图标均无效。但是,如果我直接在html页面上添加fontawesome 5作为静态字体,则会显示它们。如何在我的VueJS应用程序上使用Vanilla Fontawesome 5?

设置:

带有Encore的Symfony 4(webpack.config.js):

var Encore = require('@symfony/webpack-encore'); 
Encore
   .setOutputPath('public/build/')
   .setPublicPath('/build')
   .cleanupOutputBeforeBuild()
   .enableSourceMaps(!Encore.isProduction())
   .addStyleEntry('css/app', './assets/css/app.css')
   .addEntry('js/app', './assets/js/main.js')
   
   .enableSassLoader()
   .autoProvidejQuery()
   // Enable Vue loader
   .enableVueLoader()
;

module.exports = Encore.getWebpackConfig();

这是我的package.json:

{
    "devDependencies": {
        "@babel/core": "^7.0.0-rc.3",
        "@babel/polyfill": "^7.0.0",
        "@babel/preset-env": "^7.0.0-rc.3",
        "@symfony/webpack-encore": "^0.17.0",
        "@vue/cli-plugin-babel": "^3.0.0-rc.3",
        "babel-jest": "^23.2.0",
        "babel-loader": "^8.0.2",
        "less-loader": "^4.1.0",
        "node-sass": "^4.9.2",
        "sass-loader": "^7.1.0",
        "vue-loader": "^14",
        "vue-template-compiler": "^2.5.17",
        "webpack-notifier": "^1.6.0"
    },
    "license": "UNLICENSED",
    "private": true,
    "scripts": {
        "dev-server": "encore dev-server",
        "dev": "encore dev",
        "watch": "encore dev --watch",
        "build": "encore production"
    },
    "dependencies": {
        "@fortawesome/fontawesome-free": "^5.5.0",
        "@fortawesome/fontawesome-svg-core": "^1.2.8",
        "@fortawesome/free-solid-svg-icons": "^5.5.0",
        "@fortawesome/vue-fontawesome": "^0.1.2",
        "axios": "^0.18.0",
        "bootstrap": "^4.1.1",
        "bootstrap-vue": "^2.0.0-rc.11",
        "jquery": "^3.3.1",
        "npm": "^6.4.0",
        "style-loader": "^0.23.1",
        "sweetalert2": "^7.26.12",
        "vue": "^2.5.17",
        "vue-router": "^3.0.1",
        "vuelidate": "^0.7.4",
        "vuex": "^3.0.1"
    }
}

0 个答案:

没有答案