What can i use instead of "pretty" option now? #106
Answered
by
webdiscus
GrishaKonshin
asked this question in
Q&A
-
Since option "pretty" is deprecated how can i make resulting html in non-minified format? |
Beta Was this translation helpful? Give feedback.
Answered by
webdiscus
Mar 21, 2024
Replies: 2 comments
-
Hello @GrishaKonshin, you can use the beforeEmit option for formatting generated html. const path = require('path');
const PugPlugin = require('pug-plugin');
// module for formatting html, css, js
const pretty = require('js-beautify').html;
// formatting options: https://github.com/beautifier/js-beautify
const prettyOptions = {
html: {
indent_size: 2,
end_with_newline: true,
indent_inner_html: true,
preserve_newlines: true,
max_preserve_newlines: 0,
wrap_line_length: 120,
extra_liners: [],
space_before_conditional: true,
js: {
end_with_newline: false,
preserve_newlines: true,
max_preserve_newlines: 2,
space_after_anon_function: true,
},
css: {
end_with_newline: false,
preserve_newlines: false,
newline_between_rules: false,
},
},
};
const isDev = true; // <= you should self define it in dependency of the current mode
module.exports = {
output: {
path: path.join(__dirname, 'dist/'),
},
plugins: [
new PugPlugin({
entry: {
index: './src/index.pug',
},
beforeEmit: isDev ? (content) => pretty(content, prettyOptions) : undefined,
}),
],
}; See the option-pretty-beforeEmit test case. P.S.In next release will be implemented the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
GrishaKonshin
-
The new version new PugPlugin({
entry: {
index: './src/index.pug',
},
pretty: 'auto', // pretty formatting in development mode only
pretty: true, // pretty formatting in both modes
}), See please Pug Plugin options. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @GrishaKonshin,
you can use the beforeEmit option for formatting generated html.