From 0f5d4a5cdef2ee499bc0fe91694f0c28bc2642de Mon Sep 17 00:00:00 2001 From: Liam Hongman Cho Date: Thu, 2 May 2024 17:43:50 +0900 Subject: [PATCH 1/3] Move import statements to the top of extracted index.css file. --- rollup.config.mjs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/rollup.config.mjs b/rollup.config.mjs index 68dceacee..d1dedbc55 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -14,6 +14,7 @@ import ts2 from "rollup-plugin-typescript2" // config from package.json import pkg from "./package.json" assert {type: "json"}; import inputs from "./rollup.module-exports.mjs"; +import {readFileSync, writeFileSync} from 'fs'; const APP_VERSION_STRING = "__react_dev_mode__"; @@ -61,6 +62,41 @@ export default { extract: "dist/index.css", extensions: [".sass", ".scss", ".css"], }), + { + name: 'postcss-single-file', + async writeBundle(outputOptions, bundle) { + // Path to your CSS file + const cssFilePath = './dist/dist/index.css'; + + try { + // Read the content of the CSS file + const cssContent = readFileSync(cssFilePath, 'utf-8'); + + // Split the content into lines + const lines = cssContent.split('\n'); + + // Find lines starting with @import + const importLines = []; + const otherLines = []; + lines.forEach(line => { + if (line.trim().startsWith('@import')) { + importLines.push(line); + } else { + otherLines.push(line); + } + }); + // Combine import lines and other lines + const modifiedContent = importLines.join('\n') + '\n' + otherLines.join('\n'); + + // Write the modified content back to the file + writeFileSync(cssFilePath, modifiedContent); + + console.log('Moved @import lines to the top of the CSS file successfully.'); + } catch (error) { + console.error('Error occurred while moving @import lines to the top of the CSS file:', error); + } + }, + }, replace({ preventAssignment: false, exclude: "node_modules/**", From b023ccd3a1ce012ec311852d61caef5bfb97cbf1 Mon Sep 17 00:00:00 2001 From: Liam Hongman Cho Date: Thu, 2 May 2024 17:50:40 +0900 Subject: [PATCH 2/3] Update rollup.config.mjs Co-authored-by: Hyungu Kang | Airen --- rollup.config.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rollup.config.mjs b/rollup.config.mjs index d1dedbc55..707714560 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -14,7 +14,7 @@ import ts2 from "rollup-plugin-typescript2" // config from package.json import pkg from "./package.json" assert {type: "json"}; import inputs from "./rollup.module-exports.mjs"; -import {readFileSync, writeFileSync} from 'fs'; +import { readFileSync, writeFileSync } from 'fs'; const APP_VERSION_STRING = "__react_dev_mode__"; From d85293694934fba4e7438ecce616b651ae62cab0 Mon Sep 17 00:00:00 2001 From: Liam Hongman Cho Date: Fri, 10 May 2024 15:59:45 +0900 Subject: [PATCH 3/3] apply feeds --- rollup.config.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rollup.config.mjs b/rollup.config.mjs index 707714560..494a9adcd 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -58,7 +58,7 @@ export default { resolvecss({ code: result.css.toString() }); }), plugins: [autoprefixer], - sourceMap: true, + sourceMap: false, extract: "dist/index.css", extensions: [".sass", ".scss", ".css"], }),