-
chore: update html-bundler-webpack-plugin
-
feat: add
watchFiles.includes
andwatchFiles.excludes
options to allow watch specifically external file, e.g. *.md file included via Pug filter from any location outer project directory -
feat: add resolving the url() value in the style attribute:
div(style="background-image: url(./image.png);")
-
feat: add support for the
css-loader
optionexportType
as css-style-sheet -
feat: add
entryFilter
option to include or exclude entry files when theentry
option is the path -
feat: add support the CSS Modules for styles imported in JS using the css-loader modules option.
Required:css-loader
>=7.0.0
The CSS module rule in the webpack config:{ test: /\.(css)$/, use: [ { loader: 'css-loader', options: { modules: { localIdentName: '[name]__[local]__[hash:base64:5]', exportLocalsConvention: 'camelCase', }, }, }, ], },
CSS:
.red { color: red; } .green { color: green; }
Using in JS:
// the styles contains CSS class names: { red: 'main__red__us4Tv', green: 'main__green__bcpRp' } import styles from './main.css';
-
feat: add support for dynamic import of styles
const loadStyles = () => import('./component.scss'); loadStyles();
-
fix: issue when used js dynamic import with magic comments /* webpackPrefetch: true */ and css.inline=true
-
fix: ansi colors for verbose output in some terminals
-
fix: extract CSS from styles imported in dynamically imported JS
- feat: add experimental (undocumented) syntax to include (using
?include
query) compiled CSS directly into style tag to allow keep tag attributeswill be generatestyle(scope='some')=require('./component.scss?include')
<style scope="some"> ... CSS ... </style>
- feat: app the
pretty
andprettyOptions
options to format the generated HTML
- fix: catching of the error when a peer dependency for a Pug filter is not installed
- fix: resolving asset files on windows
- fix: avoid recompiling all entry templates after changes of a non-entry partial file, #66
Note
The
pug-plugin
since the version5.0.0
has completely new code based on the html-bundler-webpack-plugin version3.5.5
.The new version have many many new cool features, but contains some
BREAKING CHANGES
.
The Pug loader should not be defined in the module.rules
anymore.
The plugin add the pug loader automatically.
Please remove the PugPlugin.loader
from the config:
module.exports = {
mode: 'production',
output: {
path: path.join(__dirname, 'dist/'),
},
entry: {
index: './src/index.pug',
},
plugins: [
new PugPlugin(),
],
module: {
rules: [
- {
- test: /\.pug$/,
- loader: PugPlugin.loader,
- },
],
},
};
Only if you need to define the Pug options then use the new preprocessorOptions
plugin option:
module.exports = {
plugins: [
new PugPlugin({
+ preprocessorOptions: {
+ basedir: path: path.join(__dirname, 'src/'),
+ }
}),
],
};
The modules
option is removed. Use the plugin js and css options.
Instead of the modules.test
option you can use following:
- test option for template extensions
- js.test option for script extensions
- css.test option for style extensions
See new plugin options.
JS code can be inlined using the js.inline: true
option or using the ?ìnline
query:
//- OLD syntax
- script=require('./main.js?inline')
//- NEW syntax
+ script(src='./main.js?inline')
CSS code can be inlined using the css.inline: true
option or using the ?ìnline
query:
//- OLD syntax
- style=require('./style.css?inline' rel='stylesheet')
//- NEW syntax
+ link(href='./style.css?inline' rel='stylesheet')
The require() function in srcset attribute works anymore.
//- OLD syntax
Note: the required file is relative to the current pug partial file, recommends to use an webpack alias
- img(srcset=`${require('./image1.png')} 400w, ${require('@images/image2.png')} 800w` src=require('./image.png'))
//- NEW syntax
Note: the file is relative to the main entrypoint pug file, recommends to use an webpack alias
+ img(srcset=`./image1.png 400w, @images/image2.png 800w` src='./image.png')
- fix: resolve filename containing a URI fragment, e.g.:
use(href=require("./icons.svg#home"))
- chore: update npm packages
- fix: missing slash in output filename when publicPath is an url
- test: add test for bugfix with missing slash in output filename
- fix: add missing node modules to compilation after rebuild, #65
- fix: correct inline JS when used split chunks
- refactor: optimize code for script processing
- test: add manual test for missing node modules after rebuild
- fix: correct loader export when template contain CRLF line separators
- chore: bump dev packages
- test: fix testing helpers for exceptions in some cases
- test: add base test template for new issues
- docs: update readme
- fix: remove info comments before inlined SVG
- chore: update dev packages
- test: update tests
- fix: error after the process when in the template are no scripts
- fix: automatic publicPath must be empty string when used HMR
- fix: corrupted inline JS code when code contains '$$' chars chain
- fix: resolving an inline script when the
pretty
option is true - fix: inline SVG in link tag as data-URL
- refactor: improve processing of inline SVG
- DEPRECATE: use the
css
option name instead of theextractCss
- DEPRECATE: the outdated syntax of CSS option is deprecated, and in next version will be removed:
Use the new syntax, since
new PugPlugin({ modules: [ PugPlugin.extractCss({ filename: 'assets/css/[name].[contenthash].css', }), ], }),
v4.6.0
:new PugPlugin({ css: { filename: 'assets/css/[name].[contenthash].css', }, }),
- feat: add support of an inline script using the
?inline
query - fix: resolving inlined styles on windows
- refactor: optimize code and message output
- test: refactor tests
- test: add test for inline JS
- chore: update dev packages
- docs: update readme
- feat: resolve required resources in attribute blocks:
img&attributes({ src: require('./image.png'), srcset: `${require('./image1.png')} 80w, ${require('./image2.png')} 90w`, })
- feat: add the
js.verbose
option to display extract info - feat: add the
js.outputPath
optionnew PugPlugin({ js: { verbose: true, filename: '[name].[contenthash].js', outputPath: 'assets/js/', }, }),
- fix: resolving the
js.filename
option when used split chunk - fix: resolving the asset path when used the
css.outputPath
option - fix: when
css.filename
is a function, pass thepathData.filename
property as a source file - test: optimize test for new options
- docs: update readme
- feat: add short option name
css
as alias forextractCss
option. Now use the new option namecss
instead ofextractCss
:new PugPlugin({ css: { filename: 'assets/css/[name].[contenthash].css', }, }),
- feat: add new
js
option withfilename
property as alias for Webpackoutput.filename
.Thenew PugPlugin({ js: { filename: 'assets/js/[name].[contenthash].js', }, }),
js.filename
option has prio overoutput.filename
option.
- fix: CSS output path when
publicPath
hasauto
value
- fix: generate correct script asset filename by HMR after changes, sometimes filenames are mixed up between files
- fix: passing
data
in loader option when theself
loader option is true in thecompile
method - refactor: optimize code
- docs: update readme
- chore: update GitHub workflows
- feat: add resolving url() in inlined CSS using the
?inline
query
USAGE CHANGES since v4.4.0
Pug templateuse Webpack config without the type//- to inline CSS use exact the `?inline` query style=require('./styles.scss?inline')
asset/source
{ test: /\.(css|sass|scss)$/, use: ['css-loader', 'sass-loader'], }
- fix: source map in inlined CSS
- docs: update readme
- feat: add support for the inline CSS w/o supporting of url()
- fix: set default value of
output.path
aspath.join(__dirname, 'dist')
- fix: set default value of
output.filename
as[name].js
- fix: resolving of assets in pug templates with an url query
- chore: add example for usage multi-language pages with i18next
- chore: update pug-loader
- chore: update dev dependencies
- fix: resolving of modules whose package.json contains
exports
field - chore: update pug-loader
- chore: update dev dependencies
- fix: fixed last stable version of ansis in dependency
- feat: add resolving for require in Pug conditional
- feat: add resolving for require in Pug mixin argument
- feat: add resolving for require in Pug
each in
and ineach of
iteration object - fix: resolve outdated asset filenames after rebuild via webpack dev server, #42
- chore: remove warning 'scripts and styles should be specified in Pug'
- chore: update pug-loader
- chore: update dev dependencies
- fix: correct resolve output path of url() in CSS with relative public path,
if the public path is relative, then an output path of asset required not in Pug file will be auto resolved relative to the issuer - test: add the test case for correct import CSS node module contained the '.css' extension in module name, e.g. 'normalize.css'
- feat: display details verbose data for extracted CSS, images, data-URL, inline SVG, etc.
- fix: fix
info.filename
property of postprocess() argument for pug files - fix: prevents webpack generating needless alternative requests for pug files
to avoid double compiling some pug files containing the require() function - fix: the entry filename as a function is replaced by the resolved asset name to avoid redundant calling of the filename function by access to the filename property
- refactor: optimize Webpack hook functions
- refactor: optimize resolving and improve performance
- refactor: optimize verbose output
- test: add test for using pug-plugin with svgo-loader
- fix: resolve style in Pug from node_modules by module name, e.g.:
link(href=require('bootstrap') rel='stylesheet')
- fix: avoids generating a needless runtime code of css-loader in user js file when specified both style and script with using splitChunks
- chore: update pug-loader
- test: reduce test fixtures size and test time
- docs: update readme
- feat: add the
filename
property to thepathData
argument of thefilename(pathData)
function in entry object - docs: add in readme recipes how to keep original folder structure in output directory
- BREAKING CHANGE:
default value
PugPlugin.loader.option.method
is nowrender
instead ofcompile
, because it makes sense in the vast majority of use cases.
By compatibility issues (when the method was not specified), add themethod
option:
{
loader: PugPlugin.loader,
options: {
method: 'compile', // now the default method is `render`
}
},
- BREAKING CHANGE:
the
outputFile
property of the ResourceInfo (the argument ofpostprocess
function) was replaced withoutputPath
.
By compatibility issues (when in thepostprocess
was used theoutputFile
), add in your postprocess function the code line:
new PugPlugin({
postprocess: (content, info) => {
const outputFile = path.join(info.outputPath, info.assetFile); // add this line to get the removed outputFile
// ...
return content;
}
}),
- feat: add resolving of file alias for scripts and styles
- feat: improve resolving of script files specified w/o an extension
- feat: improve performance
- feat: update verbose output format to display output path and asset file separately
- feat: update pug-loader to last version optimized for using with pug-plugin
- fix: allow using url query in script source file
- fix: resolving of an absolute path using root context
- fix: resolving of alias to file using root context
- refactor: optimize code
- docs: update readme with usage examples for
render
andcompile
methods
- fix: issue by webpack serv/watch when Pug contains duplicate scripts
- fix: display warning when Pug contains duplicate scripts
- fix: verbose outputs data when asset is data URL
- feat(experimental): display a warning when using duplicate scripts or styles in the same Pug file
- fix: resolving of duplicate assets in difference style files processed via responsive-loader
- fix: auto publicPath for assets processed via responsive-loader
- fix: resolving issues on Windows
- fix: resolving issues by assets with the root path using context
- fix: issue by split chunks from some node modules
- docs: update readme for correct usage of split chunks configuration
- feat: add
extractComments
option to enable/disable saving comments in *.LICENSE.txt file - fix: split chunks for some node modules causes error
- fix: resolving of unique script filename when file required w/o extension
- fix: auto public path for windows
-
Drop support for
Node 12
, minimum supported version is14.18
- Node 12 is End-of-Life.
- Actual version of
sass-loader
13.x requires Node 14.
-
By default, the embedded CSS extractor module is now enabled. For compatibility with external extractor, you can disable extractCss module:
new PugPlugin({
extractCss: {
enabled: false, // disable embedded extractCss module to bypass extracting via external plugin
},
}),
definition of extractCss as plugin module is deprecated:
new PugPlugin({
modules: [
PugPlugin.extractCss({
filename: 'assets/css/[name].[contenthash].css',
})
],
}),
now use the new extractCss
option:
new PugPlugin({
extractCss: {
filename: 'assets/css/[name].[contenthash].css',
},
}),
Note: you can still use the
modules: []
option for custom settings.
- feat: add support auto
publicPath
- feat: add
extractCss
option for embedded CSS extract module - feat: defaults, the
extractCss
module is enabled with default options - feat: improved resolving of assets
- feat: add supports for zero config,
it means, that w/o any plugin options the pug, scss and js module will be processed with default options.
Zero confignew PugPlugin()
is equivalent to:new PugPlugin({ test: /\.(pug)$/, enabled: true, verbose: false, pretty: false, sourcePath: null, outputPath: null, filename: '[name].html', extractComments: false, extractCss: { test: /\.(css|scss|sass|less|styl)$/, enabled: true, verbose: false, filename: '[name].css', sourcePath: null, outputPath: null, }, modules: [], }),
- fix: assets resolving using auto
publicPath
- fix: remove wrong runtime files split when using splitChunks
- docs: update readme with info how to use split chunk for JS only
- fix: HMR issue on Windows
- fix: remove unused module
- feat: display the error message on broken page due to fatal error
- feat: add HMR support on broken page due to fatal error
- feat: improve url dependency resolving in styles using webpack snapshot
- refactor: optimize resolving of url in styles
- fix: resolving of relative url in deep imported style files
- fix: resolving url with a query in CSS
- fix: issue by resolving asset aliases on Windows
- fix: warning by watching interpolated dependencies with
compile
method of pug loader - docs: update readme
- fix: missing script attributes after re-compiling with HMR, #21
- fix: issue by usage webpack context with webpack alias as a relative path
- fix: issue with responsive-loader under Win10
- fix: add supports for webpack resolve modules
- fix: encode reserved chars for resource query
- fix: parse require() value with complex interpolation
- refactor: optimized working with responsible-loader
- docs: add the documentation: How to use responsive images with Pug
- fix: add support the prefixes
~
@
for file alias - chore: code cleanup, remove unused modules
- feat: add support the resolving an alias as a full path to a file in
include
- chore: update modules
- feat: add
watchFiles
loader option to watch for file changes in resolved dependencies - fix: in
:markdown
filter enable HTML tags in the markdown source - chore: add example - preview README.md
- fix: add support style types
.less
.styl
in extract CSS module - chore: update pug-loader to last version
- fix: using @import with external url
- feat: add supports for pug filter
:markdown
with highlighting code blocks
- fix: pug error in dependency requires restart of webpack
- feat: add supports for pug filters
:code
and:highlight
- chore: update pug-loader
- fix: support resolving npm modules in pug template
- feat: add supports for module type
asset/inline
the inline SVG in HTML and data-URL for binary images - feat: add supports for module type
asset/inline
the utf8 encoding for SVG data-URL in CSS - feat: add supports for module type
asset
to automatically choose betweenresource
andinline
- chor: new
hello world
web app example - test: add tests for module types
asset/inline
andasset
- feat: add the
pretty
option to format the resulting HTML
- fix: issue of resolving the js split chunks in generated html
- test: add new test for usage the pug plugin with the
responsive-loader
- refactor: code refactoring
- docs: update readme
- feat: add supports the
responsive-loader
- feat: caching of an already processed asset when the same asset is required in different issuer files
- fix: conflict of multiple styles with the same filename
- fix: resolving url() in styles required in pug
- fix: missing js file after rebuild by webpack serv
- fix: potential collision when resolving resources for
compile
method - test: caching for styles required with the same name
- fix: incorrect output directory for a module if the option
outputPath
was relative - docs: update readme
- feat: add supports the
require()
of the javascript source files directly in pug.
It is no longer necessary to define a js file in webpack entrypoint.
For example, using thepug-plugin
now is possible usage of source js files in pug:Generated HTML:script(src=require('./main.js'))
<script src='/assets/js/main.1234abcd.js'></script>
- feat: add support a function in loader option
data
forcompile
method
- feat: update pug-loader to v1.8.0 containing the resolving and watching improvements
- chore: update npm packages
- fix: the webpack option inline-source-map to save css and source map in single file
- chore: update pug-loader to the latest version
- fix: update pug-loader to fix collision with local variables passed in template function for the
compile
method
- fix: update pug-loader to fix path error in Windows when watching dependencies
-
BREAKING CHANGE (low probability): When using required style in pug, like
link(rel='stylesheet' href=require('./styles.css'))
then no need anymore thetype: 'asset/resource'
in the rule for styles.
UPDATE yourwebpack.config.js
: remove in the rule for styles (css, scss, sass, etc.) thetype
and thegenerator
fields.
Following is enough to extract CSS everywhere:{ test: /\.(css|sass|scss)$/, // type: 'asset/resource', <-- remove the type property // generator: { 'assets/css/[name].[contenthash:8].css' } <-- remove the generator property use: [ 'css-loader', 'sass-loader' ], },
To define a filename for extracted CSS use the option
filename
in theextractCss
module:new PugPlugin({ modules: [ PugPlugin.extractCss({ filename: 'assets/css/[name].[contenthash:8].css' }), ], }),
For mode details see plugin options.
-
feat: add resolving url in CSS and export resolved resource to the output path
-
feat: add caching of already resolved resources by enhanced resolver
-
feat: improved html and css extraction
-
refactor: complete refactoring of all code
-
fix: issue for the option
outputPath
-
fix: resolving issue by import styles directly from node_modules, e.g.: @import 'material-icons';
- fix: issue in module extractCss by usage the data-url in css property, #3
- fix: update pug-loader to the latest version with fixed issues
- test: add the test case for @font-face src
- feat: add extraction of the source map for CSS in separate file
- fix: no extract source map for CSS in node <=14
- chore: replace console.log with
process.stdout
by output in terminal - chore: update the pug-loader to the new version
- docs: update readme: remove unsupported substitutions
[base]
[path]
[ext]
by the option filename
- feat: update the pug-loader to the latest version supported the
htmlWebpackPlugin.options
in pug template - test: add the test case for require fonts in pug template
- refactor: tests
- docs: update readme
- fix: issue by output info with enabled verbose and filename as a function
- fix: issue by usage a query string in entry filename
- fix: issue when the same asset file is defined webpack entry-point and required in pug
- refactor: exceptions
- chore: update npm packages
- docs: update readme
- fix: issue with a path in windows
- chore: update npm packages
- fix: webpack bug in windows generating wrong backslash in url
- chore: update the
pug-loader
package
- fix: throw an exception if
output.publicPath
isundefined
orauto
- fix: real source path of required CSS file
- fix: extract styles and images via require with method
html
- feat: add support for
webpack serve
- feat: add support for require of the style source directly in pug
- feat: add ansi styling by console output
- refactor: code optimisation
- perf: improve performance
- fix: update pug-loader: fixed path issues on Windows
- feat: add option
enabled
for enable/disable the plugin - feat: add option
verbose
for show the compilation information - feat: add option
sourcePath
as the absolute path to sources - feat: add option
outputPath
as output directory for assets - feat: add option
filename
as file name of output file, can be a template string or function - feat: add option
modules
for processing different types of entries separately - feat: add module
extractCss
to fast extract CSS and source map from webpack entry withoutmini-css-extract-plugin
- test: add tests for code coverage more than 90%
- docs: update readme
First release
- feat: handles pug templates from webpack entry
- feat: zero config