Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// text
let css = JSON.stringify(src)
let code = `
var css = ${css};
var head = document.head || document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
`
output = Babel.transform(code + `export default ` + css, { presets: ['es2015'], plugins: [...es6], moduleId: path }).code
setTimeout(() => {
resolve({ output })
}, 10)
} else if (path.split('.').pop() === 'vue') {
// vue file
let info = VueCompo.getCompoInfo(src)
var scopeID = 'data-s-' + (Math.ceil(Math.random() * 100000)).toString(36)
let css = JSON.stringify(info.style)
info.template = info.template.replace('>', `${scopeID}>`)
/* eslint-disable */
let code = `
var css = ${css};
var head = document.head || document.getElementsByTagName('head')[0];
return new Promise((resolve, reject) => {
var output
try {
if (path.split('.').pop() === 'js') {
// js
output = Babel.transform(src, { presets: ['es2015'], plugins: [...es6], moduleId: path }).code
setTimeout(() => {
resolve({ output })
}, 10)
} else if (path.split('.').pop() === 'json') {
// json
output = Babel.transform(`export default ${JSON.stringify(JSON.parse(src))};`, { presets: ['es2015'], plugins: [...es6], moduleId: path }).code
setTimeout(() => {
resolve({ output })
}, 10)
} else if (path.split('.').pop() === 'html') {
// dont include html in the js file
output = ''
setTimeout(() => {
resolve({ output })
}, 10)
} else if (path.split('.').pop() === 'css') {
// text
let css = JSON.stringify(src)
let code = `
var css = ${css};
var head = document.head || document.getElementsByTagName('head')[0];
var style = document.createElement('style');
return new Promise((resolve, reject) => {
var output
try {
if (path.split('.').pop() === 'js') {
// js
output = Babel.transform(src, { presets: ['es2015'], plugins: [...es6], moduleId: path }).code
setTimeout(() => {
resolve({ output })
}, 10)
} else if (path.split('.').pop() === 'json') {
// json
output = Babel.transform(`export default ${JSON.stringify(JSON.parse(src))};`, { presets: ['es2015'], plugins: [...es6], moduleId: path }).code
setTimeout(() => {
resolve({ output })
}, 10)
} else if (path.split('.').pop() === 'html') {
// dont include html in the js file
output = ''
setTimeout(() => {
resolve({ output })
}, 10)
} else if (path.split('.').pop() === 'css') {