Skip to content

Instantly share code, notes, and snippets.

@xuecan
Created February 14, 2017 01:21
Show Gist options
  • Select an option

  • Save xuecan/019471958409cf8a422938d4b91d759f to your computer and use it in GitHub Desktop.

Select an option

Save xuecan/019471958409cf8a422938d4b91d759f to your computer and use it in GitHub Desktop.
A simple requirejs plugin for stylesheets injection.
/*!
Copyright (C) 2015-2017 Xue Can <xuecan@gmail.com> and contributors.
Licensed under the MIT license: http://opensource.org/licenses/mit-license
*/
// requirejs-css.js - A simple requirejs plugin for stylesheets injection.
define({
load: function (name, req, onload, config) {
if (!config.isBuild) {
var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = name;
document.getElementsByTagName("head")[0].appendChild(link);
}
onload(name);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment