Merge pull request #1109 from nonameShijian/PR-Branch
增加import css的支持(没有导出值)
This commit is contained in:
commit
5c95ad55e5
|
@ -60,9 +60,9 @@ self.addEventListener('fetch', event => {
|
||||||
event.respondWith(rep);
|
event.respondWith(rep);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!['.ts', '.json', '.vue'].some(ext => request.url.endsWith(ext))) return;
|
if (!['.ts', '.json', '.vue', 'css'].some(ext => request.url.endsWith(ext))) return;
|
||||||
if (request.url.endsWith('.d.ts')) return;
|
if (request.url.endsWith('.d.ts')) return;
|
||||||
if (request.url.endsWith('.json')) {
|
if (request.url.endsWith('.json') || request.url.endsWith('css')) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (!event.request.headers.get('origin')) return;
|
if (!event.request.headers.get('origin')) return;
|
||||||
}
|
}
|
||||||
|
@ -164,6 +164,14 @@ self.addEventListener('fetch', event => {
|
||||||
}
|
}
|
||||||
js = codeList.join('\n');
|
js = codeList.join('\n');
|
||||||
// console.log(js);
|
// console.log(js);
|
||||||
|
} else if (request.url.endsWith('css')) {
|
||||||
|
const id = Date.now().toString();
|
||||||
|
const scopeId = `data-v-${ id }`;
|
||||||
|
js = `const style = document.createElement('style');
|
||||||
|
style.setAttribute('type', 'text/css');
|
||||||
|
style.setAttribute('data-vue-dev-id', \`${ scopeId }\`);
|
||||||
|
style.textContent = ${ JSON.stringify(text) };
|
||||||
|
document.head.appendChild(style);`;
|
||||||
}
|
}
|
||||||
const rep = new Response(new Blob([js], { type: "text/javascript" }), {
|
const rep = new Response(new Blob([js], { type: "text/javascript" }), {
|
||||||
status: 200,
|
status: 200,
|
||||||
|
|
Loading…
Reference in New Issue