美文网首页Ionic 3技术汇总
ionic3打包--prod,报错字体文件找不到

ionic3打包--prod,报错字体文件找不到

作者: IT飞牛 | 来源:发表于2019-02-14 15:41 被阅读0次

    问题截图:

    image.png
    (场景还原:ionic serve运行后,执行ionic cordova build android --prod打包,然后刷新页面。打包过程重新生成了一遍www)

    1、安装copyfiles 插件

    npm install copyfiles --save
    

    2、创建文件hooks/copy-fonts.js:

    var copyfiles = require('copyfiles');
    module.exports = function (context) {
        copyfiles([
            'node_modules/ionic-angular/fonts/roboto-regular.ttf',
            'node_modules/ionic-angular/fonts/roboto-regular.woff',
            'node_modules/ionic-angular/fonts/roboto-regular.woff2',
            'node_modules/ionic-angular/fonts/roboto-medium.ttf',
            'node_modules/ionic-angular/fonts/roboto-medium.woff',
            'node_modules/ionic-angular/fonts/roboto-medium.woff2',
            'node_modules/ionic-angular/fonts/roboto-bold.ttf',
            'node_modules/ionic-angular/fonts/roboto-bold.woff',
            'node_modules/ionic-angular/fonts/roboto-bold.woff2',
            'www/assets/fonts'
        ],
        true,
        function (){ console.log("The font files has been copied");}
          );
    };
    

    3、在config.xml中配置

    <hook src="src/assets/js/hooks/copy-fonts.js" type="after_prepare" />
    

    找到答案的网站:【Ionic build –prod IOS stops without a error message
    补充资料:【关于config.xml的详细说明

    相关文章

      网友评论

        本文标题:ionic3打包--prod,报错字体文件找不到

        本文链接:https://www.haomeiwen.com/subject/cvmeeqtx.html