Use prettier to format the HTML before saving
This commit is contained in:
parent
15b5236e2e
commit
6c0f9f5e7c
@ -4,7 +4,7 @@
|
|||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"compile": "esbuild ssg/build.tsx --bundle --outfile=.tmp/ssg/build.js --jsx-import-source=@kitajs/html --minify --sourcemap --platform=node --external:esbuild",
|
"compile": "esbuild ssg/build.tsx --bundle --outfile=.tmp/ssg/build.js --jsx-import-source=@kitajs/html --minify --sourcemap --platform=node --external:esbuild --external:prettier",
|
||||||
"buld": "npm run compile && node .tmp/ssg/build.js"
|
"buld": "npm run compile && node .tmp/ssg/build.js"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
|
@ -4,6 +4,7 @@ import { mkdirSync, writeFileSync, rmSync } from 'node:fs';
|
|||||||
import { sassPlugin } from 'esbuild-sass-plugin';
|
import { sassPlugin } from 'esbuild-sass-plugin';
|
||||||
import Root from './root';
|
import Root from './root';
|
||||||
import { getPaths, getStylePath, outDir } from './utils';
|
import { getPaths, getStylePath, outDir } from './utils';
|
||||||
|
import { format } from 'prettier';
|
||||||
|
|
||||||
mkdirSync(outDir, { recursive: true });
|
mkdirSync(outDir, { recursive: true });
|
||||||
|
|
||||||
@ -38,12 +39,14 @@ void (async () => {
|
|||||||
const html = Page.default();
|
const html = Page.default();
|
||||||
let stylePaths: string[] = getStylePath(tmpJsPath, outputHtmlPath);
|
let stylePaths: string[] = getStylePath(tmpJsPath, outputHtmlPath);
|
||||||
|
|
||||||
writeFileSync(
|
const formattedHtml = await format(
|
||||||
outputHtmlPath,
|
|
||||||
<Root title="My App" stylePaths={stylePaths} scriptPaths={[]}>
|
<Root title="My App" stylePaths={stylePaths} scriptPaths={[]}>
|
||||||
{html}
|
{html}
|
||||||
</Root>,
|
</Root>,
|
||||||
|
{ parser: 'html' },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
writeFileSync(outputHtmlPath, formattedHtml);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user