From d233457e48d0fb779030b8406f6c1ec41eefe541 Mon Sep 17 00:00:00 2001 From: danieletulone Date: Fri, 27 Jan 2023 12:49:18 +0100 Subject: [PATCH 01/18] Add cssInline option. --- src/index.ts | 12 ++++++++++++ src/options.ts | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/src/index.ts b/src/index.ts index c4a7c38..c676d3e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -295,6 +295,18 @@ const vuePlugin = (opts: Options = {}) => { } } + if (opts.cssInline) { + const cssText = result.code; + const cssId = 'id-' + id; + const contents = `if (!document.getElementById('${cssId}')){const s=document.createElement("style");s.textContent=\`${cssText}\`;s.id='${cssId}';document.head.append(s)}`; + return { + contents, + loader: "js", + resolveDir: path.dirname(args.path), + watchFiles: includedFiles + }; + } + return { contents: result.code, loader: "css", diff --git a/src/options.ts b/src/options.ts index 64cee07..dd35b33 100644 --- a/src/options.ts +++ b/src/options.ts @@ -65,6 +65,13 @@ export type Options = { plugins?: any[]; } + /** + * If enabled it will output css of