-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add pretty formatting html using beforeEmit
- Loading branch information
Showing
5 changed files
with
88 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
test/cases/_experimental/option-pretty-beforeEmit/expected/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Test</title> | ||
</head> | ||
<body> | ||
<h1>Hello World!</h1> | ||
</body> | ||
</html> |
5 changes: 5 additions & 0 deletions
5
test/cases/_experimental/option-pretty-beforeEmit/src/index.pug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
html | ||
head | ||
title Test | ||
body | ||
h1 Hello World! |
57 changes: 57 additions & 0 deletions
57
test/cases/_experimental/option-pretty-beforeEmit/webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
const path = require('path'); | ||
const PugPlugin = require('@test/pug-plugin'); | ||
|
||
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; | ||
|
||
module.exports = { | ||
mode: 'production', | ||
|
||
output: { | ||
path: path.join(__dirname, 'dist/'), | ||
}, | ||
|
||
plugins: [ | ||
new PugPlugin({ | ||
entry: { | ||
index: './src/index.pug', | ||
}, | ||
beforeEmit: isDev ? (content) => pretty(content, prettyOptions) : undefined, | ||
}), | ||
], | ||
|
||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(css|sass|scss)$/, | ||
use: ['css-loader', 'sass-loader'], | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters