【问题标题】:Angular2 asp.net core. What exactly is vendor.css for?Angular2 asp.net 核心。 vendor.css 到底是干什么用的?
【发布时间】:2018-07-20 23:10:20
【问题描述】:

我是 bootstrap 的忠实粉丝,我来自 php 世界。我最近开始使用 angular2 和 asp.net 核心。我注意到一个 vendor.css 文件在打开时也包含引导程序。

npm 已经安装了 bootstrap,并且 wwwroot lib 文件夹中有 bootstrap.min 文件。

我对这个文件感到困惑。它是干什么用的?用bootstrap不是多余吗?

【问题讨论】:

    标签: angular asp.net-core angular-ui-bootstrap


    【解决方案1】:

    当我们发布一个应用程序时,wwwroot 文件夹中的所有文件都会被复制。然后,如果你需要在 index.html 中加载一个 .css,或者一个 dbs,或者一个图像或者.. 你必须

    但在 Angular 中,最好的方法是拥有一个 unique.css。这个 css 是你的组件中 css 的联合+全局定义的 css。

    在 angular-cli 中,我们使用 angular-cli.json 文件来全局添加 .css(在样式中)

    "styles": [
            "app/css/bootstrap.css",
            "../node_modules/font-awesome/css/font-awesome.css",
            "styles.css"
          ],
    

    在 .net Core 中,我们使用 webpack.config.vendor 全局添加 .css(在 nonTreeShakableModules 中)

    const nonTreeShakableModules = [
        'bootstrap-css-only/css/bootstrap.css',
        'font-awesome/css/font-awesome.css',
        'es6-promise',
        'es6-shim',
        'event-source-polyfill'
    ];
    

    此外,在 .net Core 中我们也可以使用 vendor.css

    【讨论】:

      【解决方案2】:

      在 Angular2 项目中,还有其他供应商包使用 css 文件。

      【讨论】:

        【解决方案3】:

        vendor.css 是您需要所有第三方 css 文件的地方。
        所有这些文件都将内联到dist/vendor.css

        根据Angular CLI documentation

        【讨论】:

          猜你喜欢
          • 2018-07-27
          • 2016-12-29
          • 1970-01-01
          • 1970-01-01
          • 2020-05-03
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-07-17
          相关资源
          最近更新 更多