Skip to content

Instantly share code, notes, and snippets.

@egoist

egoist/input.js Secret

Created March 1, 2018 06:29
Show Gist options
  • Save egoist/7460f76907edc8eea578154db8cc328a to your computer and use it in GitHub Desktop.
Save egoist/7460f76907edc8eea578154db8cc328a to your computer and use it in GitHub Desktop.
Created by gist-it (https://github.com/egoist/gist-it)
import './a.css'
(function () {
'use strict';
function styleInject(css, ref) {
if ( ref === void 0 ) ref = {};
var insertAt = ref.insertAt;
if (!css || typeof document === 'undefined') { return; }
var head = document.head || document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
if (insertAt === 'top') {
if (head.firstChild) {
head.insertBefore(style, head.firstChild);
} else {
head.appendChild(style);
}
} else {
head.appendChild(style);
}
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
}
var css = "body {\n color: red;\n}\n";
styleInject(css);
}());
{
"name": "test",
"version": "1.0.0",
"license": "MIT",
"devDependencies": {
"rollup": "^0.56.3",
"rollup-plugin-commonjs": "^8.3.0",
"rollup-plugin-node-resolve": "^3.0.3",
"rollup-plugin-postcss": "^1.3.1"
}
}
export default {
input: './input.js',
output: {
file: 'out.js',
format: 'iife'
},
plugins: [
require('rollup-plugin-node-resolve')({ jsnext: true, main: true, browser: true }),
require('rollup-plugin-commonjs')(),
require('rollup-plugin-postcss')()
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment