Skip to content

Commit

Permalink
upd: #1278; preloadStrategy -> preload-js; cont;
Browse files Browse the repository at this point in the history
  • Loading branch information
migbash committed Aug 2, 2023
1 parent 0de9bfd commit 3161e45
Showing 1 changed file with 76 additions and 76 deletions.
152 changes: 76 additions & 76 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,85 +30,85 @@ export default defineConfig
// ### 'this' plugin removes all 'CSS' from standard
// ### importing by 'svelte/svelteki' and styles will be missing
// ### if not imported as a '<link ... >' in the 'src/app.html'
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
): string =>
{

const generateOneCssFile: boolean = false;

if (generateOneCssFile)
{
// ### NOTE:
// ### the 'cssCode' generated contains some 'formatting' issues.
// ### remove 1st and last speech marks.
// ### remove cases of `\n` chars.
// ### correct custom case of 'ids'/'classes' using the 'forward-slash' in the declaration.
let cssCodeMod: string = cssCode.slice(1, -1);
cssCodeMod = cssCodeMod.replace(/\\n/g, "");
cssCodeMod = cssCodeMod.replace(/\\\\/g,"\\")

// ### WARNING:
// ### 'all-css-chunk.css' must exist inside '/static'
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
// ): string =>
// {

// const generateOneCssFile: boolean = false;

// if (generateOneCssFile)
// {
// // ### NOTE:
// // ### the 'cssCode' generated contains some 'formatting' issues.
// // ### remove 1st and last speech marks.
// // ### remove cases of `\n` chars.
// // ### correct custom case of 'ids'/'classes' using the 'forward-slash' in the declaration.
// let cssCodeMod: string = cssCode.slice(1, -1);
// cssCodeMod = cssCodeMod.replace(/\\n/g, "");
// cssCodeMod = cssCodeMod.replace(/\\\\/g,"\\")

// // ### WARNING:
// // ### 'all-css-chunk.css' must exist inside '/static'
// 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: {
rollupOptions:
{
output:
{
manualChunks: undefined
}
}
},
// build: {
// rollupOptions:
// {
// output:
// {
// manualChunks: undefined
// }
// }
// },

// ### NOTE:
// ### 'vitest' integration
Expand Down

0 comments on commit 3161e45

Please sign in to comment.