Skip to content

Commit

Permalink
issue: #1278; cont;
Browse files Browse the repository at this point in the history
  • Loading branch information
migbash committed Jul 26, 2023
1 parent 8d4f519 commit 56fb9db
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 109 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"staging": "npm run dev -- --mode staging",
"build": "vite build",
"preview": "vite preview --host --port 4173",
"quick:preview:local:spin": "vite build && npm run preview",
"preview:1-click:spin": "npm run build && npm run preview",
"start": "node build/index.js",
"start:docker": "node server-docker.js",
"start:heroku": "node server-heroku.js",
Expand Down
30 changes: 19 additions & 11 deletions src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
href="/app.css"
/>

<link
<!-- <link
rel="preload"
href="/all-css-chunk.css"
as="style"
Expand All @@ -35,7 +35,18 @@
rel="stylesheet"
type="text/css"
href="/all-css-chunk.css"
/>
/> -->
<!-- <link rel="stylesheet" href="/all-css-chunk.css" media="print" onload="this.media='all'" /> -->

<!-- <style>
div#seo-widget-box
{
position: fixed;
z-index: -100000000;
top: -999999px;
left: -999999px;
}
</style> -->

<!--
IMPORTANT
Expand Down Expand Up @@ -168,10 +179,10 @@
NOTE:
PostHog Snippet
-->
<script>
<!-- <script>
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init('phc_BJqoj9AaGVmHswffX8staKXtGjUmfCBjckzJID7PzQ6',{api_host:'https://app.posthog.com'})
</script>
</script> -->

<!--
GOOGLE ANALYTICS
Expand All @@ -194,7 +205,7 @@
<!--
GOOGLE ANALYTICS GA4
-->
<script
<!-- <script
async
src="https://www.googletagmanager.com/gtag/js?id=G-LDMRQC7B7Z"
>
Expand All @@ -205,7 +216,7 @@
gtag('js', new Date());
gtag('config', 'G-LDMRQC7B7Z');
</script>
</script> -->

<!--
IMPORTANT
Expand All @@ -215,13 +226,10 @@

<body
data-sveltekit-preload-data="hover"
>
>

<div
id=
"
svelte
"
id="svelte"
>
%sveltekit.body%
</div>
Expand Down
53 changes: 9 additions & 44 deletions src/lib/components/SEO-Box.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,24 @@ COMPONENT JS (w/ TS)
=================-->

<script lang="ts">
import { browser } from "$app/environment";
//#region ➤ [MAIN] Package Imports
// IMPORTS GO HERE
//#endregion ➤ [MAIN] Package Imports
//#region ➤ [VARIABLES]
// ~~~~~~~~~~~~~~~~~~~~~
// COMPONENT VARIABLES
// ~~~~~~~~~~~~~~~~~~~~~
//#endregion ➤ [VARIABLES]
//#region ➤ [METHODS]
// ~~~~~~~~~~~~~~~~~~~~~
// COMPONENT METHODS
// ~~~~~~~~~~~~~~~~~~~~~
// -Methods Go Here
function do_something() {}
// ~~~~~~~~~~~~~~~~~~~~~
// VIEWPORT CHANGES
// ~~~~~~~~~~~~~~~~~~~~~
//#endregion ➤ [METHODS]
//#region ➤ [ONE-OFF] [METHODS] [IF]
//#endregion ➤ [ONE-OFF] [METHODS] [IF]
//#region ➤ [REACTIVIY] [METHODS]
//#endregion ➤ [REACTIVIY] [METHODS]
//#region ➤ SvelteJS/SvelteKit [LIFECYCLE]
import { browser } from "$app/environment";
//#endregion ➤ SvelteJS/SvelteKit [LIFECYCLE]
//#endregion ➤ [MAIN] Package Imports
</script>

<!-- ===============
COMPONENT HTML
COMPONENT HTML
NOTE: [HINT] use (CTRL+SPACE) to select a (class) (id) style
=================-->

{#if !browser}
<div
id="seo-widget-box">
id="seo-widget-box"
>
<slot>
</slot>
</div>
Expand All @@ -69,9 +33,10 @@ NOTE: [HINT] auto-fill/auto-complete iniside <style> for var() values by typing/

<style>
#seo-widget-box {
position: absolute;
z-index: -100;
div#seo-widget-box
{
position: fixed;
z-index: -100000000;
top: -999999px;
left: -999999px;
}
Expand Down
106 changes: 53 additions & 53 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,59 +28,59 @@ export default defineConfig

viteCompression(),

cssInjectedByJsPlugin
(
{

// relativeCSSInjection: true

// topExecutionPriority: true,

// jsAssetsFilterFunction: function customJsAssetsfilterFunction
// (
// outputChunk
// )
// {

// // [🐞]
// // ### NOTE:
// // ### It appears, the 'outputChunk.filename' is of type:
// // ### - _app/immutable/chunks/index.088b98a6.js
// // ### - _app/immutable/chunks/index.8e8ca4ce.js
// // ### etc.
// // console.log(outputChunk.fileName);

// return outputChunk.fileName == 'index.js';
// }

// ### NOTE:
// ### definitive 'hack' solution for 'single CSS file' output chunk.
injectCode:
(
cssCode,
options
) =>
{

const cssCodeMod = cssCode.slice(1, -1);

fs.writeFile
(
'./static/all-css-chunk.css',
cssCodeMod,
err =>
{
if (err) console.error(err);
}
);

return '';

// return `try{if(typeof document != 'undefined'){var elementStyle = document.createElement('style');elementStyle.appendChild(document.createTextNode(${cssCode}));document.head.appendChild(elementStyle);}}catch(e){console.error('vite-plugin-css-injected-by-js', e);}`
}

}
),
// cssInjectedByJsPlugin
// (
// {

// relativeCSSInjection: true,

// // topExecutionPriority: true,

// // jsAssetsFilterFunction: function customJsAssetsfilterFunction
// // (
// // outputChunk
// // )
// // {

// // // [🐞]
// // // ### NOTE:
// // // ### It appears, the 'outputChunk.filename' is of type:
// // // ### - _app/immutable/chunks/index.088b98a6.js
// // // ### - _app/immutable/chunks/index.8e8ca4ce.js
// // // ### etc.
// // // console.log(outputChunk.fileName);

// // return outputChunk.fileName == 'index.js';
// // }

// // ### NOTE:
// // ### definitive 'hack' solution for 'single CSS file' output chunk.
// injectCode:
// (
// cssCode,
// options
// ) =>
// {

// const cssCodeMod: string = cssCode.slice(1, -1);

// fs.writeFile
// (
// './static/all-css-chunk.css',
// cssCodeMod,
// err =>
// {
// if (err) console.error(err);
// }
// );

// return '';

// // return `try{if(typeof document != 'undefined'){var elementStyle = document.createElement('style');elementStyle.appendChild(document.createTextNode(${cssCode}));document.head.appendChild(elementStyle);}}catch(e){console.error('vite-plugin-css-injected-by-js', e);}`
// }

// }
// ),
],
// DOC: REF: [6]
build: {
Expand Down

0 comments on commit 56fb9db

Please sign in to comment.