Skip to content

Commit

Permalink
feat: disable default attribute sorting
Browse files Browse the repository at this point in the history
Still can be enabled with html.sort_attributes option
  • Loading branch information
muryoh committed Nov 20, 2023
1 parent c9d3d77 commit af2d19e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/compressors/html.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { minify } from 'html-minifier-terser';
import { compressCSS } from './css.js';
import { compressJS } from './js.js';
import config from '../config.js';

async function minifyJSinHTML(originalCode: string): Promise<string> {
const newCode = await compressJS(originalCode);
Expand All @@ -27,7 +28,7 @@ export async function compressHTML(originalCode: Buffer): Promise<Buffer> {
minifyCSS: minifyCSSinHTML,
minifyJS: minifyJSinHTML,
sortClassName: true,
sortAttributes: true,
sortAttributes: config.html.sort_attributes,
});

if (newhtmlData) return Buffer.from(newhtmlData, 'utf-8');
Expand Down
1 change: 1 addition & 0 deletions src/config-default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Options } from './config-types.js';
const default_options: Options = {
html: {
add_css_reset_as: 'inline',
sort_attributes: false,
},
css: {
inline_critical_css: false,
Expand Down
1 change: 1 addition & 0 deletions src/config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type Options = {
":where(img){height:auto}"
*/
add_css_reset_as: 'inline' | 'off';
sort_attributes: boolean;
};
js: {
compressor: 'esbuild' | 'swc'; // swc have smaller result but can break code (seen with SvelteKit code)
Expand Down

0 comments on commit af2d19e

Please sign in to comment.