在<head>中导入CSS和控制顺序使用 jspm 和 system.js [英] Importing CSS and controlling order in <head> using jspm and system.js

查看:23
本文介绍了在<head>中导入CSS和控制顺序使用 jspm 和 system.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Aurelia 应用中编写了以下内容

I've written the following in an Aurelia app

import "bootstrap/css/bootstrap.css!";
import "./app.css!";

我希望 app.css 排在第二位,因为它会覆盖 bootstrap.css 样式.但是,我首先获取 app.css,因为我假设 system.js 加载器正在并行运行它们,并且 app.css 是两者中较小的一个,因此它首先加载.

and I want app.css second in since it overrides bootstrap.css styles. However, I'm getting app.css first since I presume the system.js loader is running them in parallel and since app.css is the smaller of the two it gets loaded first.

jspm 有没有办法定义这两个文件之间的依赖关系来控制它们的加载顺序,还有其他方法吗?

Is there a way in jspm to define a dependency between these two files to control their loading order is is there some other way?

非常感谢!:)

推荐答案

您可以尝试使用 System.import 导入 css.例如.在您的 index.html 中:

You could try to import the css using System.import. E.g. in your index.html:

System.import('bootstrap/css/bootstrap.css!').then(() => {
    System.import('./app.css!');
});

但请记住,通过这种方式,您必须确保 system.js 与您的应用程序一起提供.因此,您无法将整个应用捆绑为一个自动执行的捆绑包.

But keep in mind that this way you have to make sure that system.js is served with your app. So you can't bundle your whole app as an self-executing bundle.

这篇关于在<head>中导入CSS和控制顺序使用 jspm 和 system.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆