Skip to content

Commit

Permalink
fix: initialize the singleton of the Config only once
Browse files Browse the repository at this point in the history
  • Loading branch information
webdiscus committed Mar 3, 2024
1 parent b156817 commit 80264f5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change log

## 3.5.5 (2024-03-03)

- fix: initialize the singleton of the Config only once

## 3.5.4 (2024-03-03)

- optimize: lazy load the plugin config file
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ See [boilerplate](https://github.com/webdiscus/webpack-html-scss-boilerplate)
- [integrityHashes](#hook-integrity-hashes)
1. [Plugin options](#plugin-options)
- [test](#option-test) (RegEx to handle matching templates)
- [entry](#option-entry) (entry as a list of template files)
- [entry](#option-entry) (template as entry point)
- [entry as an array](#option-entry-array) (array notation)
- [entry as an object](#option-entry-object) (object notation)
- [entry as a path](#option-entry-path) (find templates in a directory recursively)
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "html-bundler-webpack-plugin",
"version": "3.5.4",
"version": "3.5.5",
"description": "HTML bundler plugin for webpack handles a template as an entry point, extracts CSS and JS from their sources referenced in HTML, supports template engines like Eta, EJS, Handlebars, Nunjucks.",
"keywords": [
"html",
Expand Down Expand Up @@ -80,6 +80,10 @@
"types": "./plugins/favicons-bundler-plugin/index.d.ts",
"require": "./plugins/favicons-bundler-plugin/index.js",
"import": "./plugins/favicons-bundler-plugin/index.js"
},
"./Config": {
"require": "./src/Common/Config.js",
"import": "./src/Common/Config.js"
}
},
"engines": {
Expand Down
11 changes: 7 additions & 4 deletions src/Common/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ class Config {
};

static init(file) {
this.#configFile = path.isAbsolute(file)
? require.resolve(file)
: // path relative to `./src/Common`
require.resolve(path.join('../', file));
// initialize only once
if (!this.#configFile) {
this.#configFile = path.isAbsolute(file)
? require.resolve(file)
: // path relative to `./src/Common`
require.resolve(path.join('../', file));
}
}

static get() {
Expand Down

0 comments on commit 80264f5

Please sign in to comment.