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