简体   繁体   English

angular.json 中自动添加脚本和样式

[英]Automatically add scripts and styles in angular.json

My goal is simply to add the scripts and styles automatically in angular.json using the command line.For example if I am installing bootstrap in my angular project using the following the command.我的目标只是使用命令行在 angular.json 中自动添加脚本和样式。例如,如果我使用以下命令在我的角度项目中安装引导程序。

npm install bootstrap

I have to manually goto angular.json and add the bootstrap.min.css and bootstrap.min.js.我必须手动转到 angular.json 并添加 bootstrap.min.css 和 bootstrap.min.js。

        "styles": [
          "src/styles.css",
          "node_modules/bootstrap/dist/css/bootstrap.min.css",

        ],
        "scripts": [
          "node_modules/jquery/dist/jquery.min.js",
          "node_modules/popper.js/dist/umd/popper.min.js",
          "node_modules/bootstrap/dist/js/bootstrap.min.js",

        ]

Is there a way to do this with a command?有没有办法用命令来做到这一点? The reason why I need this because i am using my custom library and have its dependencies installed.Since custom libraries dont have any angular.json, the custom library gets installed but could not figure out a way to add the scripts and styles.我需要这个的原因是因为我正在使用我的自定义库并安装了它的依赖项。由于自定义库没有任何 angular.json,自定义库已安装但无法找到添加脚本和样式的方法。

What I did was to add the script on the src/index.html file for it to be always bundled.我所做的是将脚本添加到 src/index.html 文件中,以便始终将其捆绑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM