Skip to content

Releases: webdiscus/pug-plugin

v4.9.9

12 Aug 16:13
Compare
Choose a tag to compare

Cumulative Release v4.1.0 - v4.9.9

Features

  • Added support of an inline script using the ?inline query.

  • Resolve required resources in attribute blocks:

    img&attributes({
      src: require('./image.png'),
      srcset: `${require('./image1.png')} 80w, ${require('./image2.png')} 90w`,
    })
  • Added the js.verbose option to display extract info.

  • Added the js.outputPath option:

    new PugPlugin({
      js: {
        verbose: true,
        filename: '[name].[contenthash].js',
        outputPath: 'assets/js/',
      },
    }),
  • Added short option name css as alias for extractCss option.
    Now use the new option name css instead of extractCss:

    new PugPlugin({
      css: {
        filename: 'assets/css/[name].[contenthash].css',
      },
    }),
  • Added new js option with filename property as alias for Webpack output.filename:

    new PugPlugin({
      js: {
        filename: 'assets/js/[name].[contenthash].js',
      },
    }),

    The js.filename option has prio over output.filename option.

  • Added resolving url() in inlined CSS using the ?inline query
    USAGE CHANGES since v4.4.0
    Pug template

    //- to inline CSS use exact the `?inline` query
    style=require('./styles.scss?inline')

    use Webpack config without the type asset/source

    {
      test: /\.(css|sass|scss)$/,
      use: ['css-loader', 'sass-loader'],
    }
  • Added support for the inline CSS w/o supporting of url().

  • Added resolving for require in Pug conditional.

  • Added resolving for require in Pug mixin argument.

  • Added resolving for require in Pug each in and in each of iteration object.

  • display details verbose data for extracted CSS, images, data-URL, inline SVG, etc.

  • Added the filename property to the pathData argument of the filename(pathData) function in entry object.

DEPRECATIONS

  • Use the css option name instead of the extractCss.
  • The outdated syntax of CSS option is deprecated, and in next version will be removed:
    new PugPlugin({
      modules: [
        PugPlugin.extractCss({
          filename: 'assets/css/[name].[contenthash].css',
        }),
      ],
    }),
    
    Use the new syntax, since v4.6.0:
    new PugPlugin({
      css: {
        filename: 'assets/css/[name].[contenthash].css',
      },
    }),
    

Bug Fixes

  • Resolve filename containing a URI fragment, e.g.:
    use(href=require("./icons.svg#home"))
  • Fixed missing slash in output filename when publicPath is an url.
  • Added missing node modules to compilation after rebuild, #65.
  • Correct inline JS when used split chunks.
  • Correct loader export when template contain CRLF line separators.
  • Remove info comments before inlined SVG.
  • Fixed error after the process when in the template are no scripts.
  • Auto publicPath must be empty string when used HMR.
  • Fixed corrupted inline JS code when code contains '$$' chars chain.
  • Resolve an inline script when the pretty option is true.
  • Inline SVG in link tag as data-URL.
  • Resolve inlined styles on windows.
  • Resolve the js.filename option when used split chunk.
  • Resolve the asset path when used the css.outputPath option.
  • When css.filename is a function, pass the pathData.filename property as a source file.
  • Fixed CSS output path when publicPath has auto value.
  • Generate correct script asset filename by HMR after changes, sometimes filenames are mixed up between files.
  • Pass data in loader option when the self loader option is true in the compile method.
  • Fixed source map in inlined CSS.
  • Set default value of output.path as path.join(__dirname, 'dist').
  • Set default value of output.filename as [name].js.
  • Resolve assets in pug templates with an url query.
  • Resolve modules whose package.json contains exports field.
  • Fixed last stable version of ansis in dependency.
  • Resolve outdated asset filenames after rebuild via webpack dev server, #42.
  • 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.
  • Fixed info.filename property of postprocess() argument for pug files.
  • Fixed 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.
  • Prevent to webpack generate needless alternative requests for pug files to avoid double compiling some pug files containing the require() function.
  • Resolve style in Pug from node_modules by module name, e.g.: link(href=require('bootstrap') rel='stylesheet').
  • Avoid generating a needless runtime code of css-loader in user js file when specified both style and script with using splitChunks.

v4.0.0

03 Aug 17:47
Compare
Choose a tag to compare

⚠ BREAKING CHANGES

  • Default value PugPlugin.loader.option.method is now render instead of compile,
    because it makes sense in the vast majority of use cases.
    By compatibility issues (when the method was not specified), add the method option:
{
  loader: PugPlugin.loader,
  options: {
    method: 'compile', // now the default method is `render`
  }
},
  • The outputFile property of the ResourceInfo (the argument of postprocess function) was replaced with outputPath.
    By compatibility issues (when in the postprocess was used the outputFile), 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;
  }
}),

Features

  • improve performance
  • improve resolving of script files specified w/o extension
  • add resolving of file alias for scripts and styles
  • update verbose output format to display output path and asset file separately
  • update pug-loader to last version optimized for using with pug-plugin
  • display a warning when used duplicate scripts or styles in same Pug file

Fixes

  • resolving of absolute path using root context
  • resolving of alias to file using root context
  • allow to use url query in script source file
  • verbose outputs data when asset is data URL

v3.0.0

17 Jul 16:09
Compare
Choose a tag to compare

⚠ BREAKING CHANGES

  • Drop support for Node 12, minimum supported version is 14.18

    • Node 12 is End-of-Life.
    • Actual version of sass-loader 13.x requires Node 14.
  • Defaults 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
  },
}),

⚠ DEPRECATION

Definition of PugPlugin.extractCss as plugin module is deprecated because this module is enabled by default.
Following definition is deprecated:

new PugPlugin({
  modules: [
    PugPlugin.extractCss({
      filename: 'assets/css/[name].[contenthash].css',
    })
  ],
}),

Now use the new extractCss option to configure the embedded CSS extractor module:

new PugPlugin({
  extractCss: {
    filename: 'assets/css/[name].[contenthash].css',
  },
}),

Features

  • add support auto publicPath
  • add extractCss option for embedded CSS extract module
  • defaults, the extractCss module is enabled with default options
  • improved resolving of assets
  • display the error message on broken page due to fatal error
  • add supports for pug filters :escape, :code, :highlight and :markdown
  • add supports for module type asset/inline the inline SVG in HTML and data-URL for binary images
  • add supports for module type asset/inline the utf8 encoding for SVG data-URL in CSS
  • add supports for module type asset to automatically choose between resource and inline
  • add supports for zero config,
    it means, that w/o any plugin options the pug and style modules will be processed with default options.
    Zero config new PugPlugin() is equivalent to:
    new PugPlugin({
      test: /\.(pug)$/,
      enabled: true,
      verbose: false,
      pretty: false,
      sourcePath: null,
      outputPath: null,
      filename: '[name].html',
      extractCss: {
        test: /\.(css|scss|sass|less|styl)$/,
        enabled: true,
        verbose: false,
        filename: '[name].css',
        sourcePath: null,
        outputPath: null,
      },
      modules: [],
    }),

v2.2.0

22 Apr 13:59
Compare
Choose a tag to compare

Features

  • add support for usage the js source files directly in pug, instead of define them in webpack entry
  • add the pretty option to format the resulting HTML
  • add support for responsive-loader to use a result of this loader in pug
  • improve passing data for compile method of pug-loader, now is possible pass an object contained a function
  • improve caching of an already processed same asset in different issuer files

Bugfixes

  • fix compatibility wit node 12
  • fix issue of resolving the js split chunks in generated html
  • 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 incorrect output directory for a module if the option outputPath was relative

v1.2.0

12 Jan 12:35
Compare
Choose a tag to compare
  • added support webpack serve
  • added support require of a style directly in pug
  • added ansi styling by console output
  • improve performance