unplugin-version-injector 2.0.0-beta.2 → 2.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rollup.js CHANGED
@@ -35,17 +35,21 @@ function defaultFormatDate(date) {
35
35
  function createVersionInjector(options = {}) {
36
36
  var _a, _b;
37
37
  const version = (_a = options.version) != null ? _a : getPackageVersion();
38
- ((_b = options.formatDate) != null ? _b : defaultFormatDate)(/* @__PURE__ */ new Date());
38
+ const buildTime = ((_b = options.formatDate) != null ? _b : defaultFormatDate)(/* @__PURE__ */ new Date());
39
39
  const metaTag = `<meta name="version" content="${version}">
40
40
  `;
41
- const logScript = `<script data-injected="unplugin-version-injector">console.log(...)</script>`;
41
+ const logScript = `
42
+ <script data-injected="unplugin-version-injector">
43
+ console.log("%c Version: ${version} ", "background: #222; color: #00ff00; font-size: 12px; padding: 4px; border-radius: 4px;");
44
+ console.log("%c Build Time: ${buildTime} ", "background: #222; color: #ffcc00; font-size: 12px; padding: 4px; border-radius: 4px;");
45
+ </script>`;
42
46
  return function processHtml(html) {
43
47
  if (!html.includes('<meta name="version"')) {
44
- html = html.replace(/<head>/, `<head>
48
+ html = html.replace(/<head>/i, `<head>
45
49
  ${metaTag}`);
46
50
  }
47
- if (!html.includes('<script data-injected="unplugin-version-injector"')) {
48
- html = html.replace("</body>", ` ${logScript}
51
+ if (options.log !== false && !html.includes('data-injected="unplugin-version-injector"')) {
52
+ html = html.replace(/<\/body>/i, ` ${logScript}
49
53
  </body>`);
50
54
  }
51
55
  return html;
package/dist/rollup.mjs CHANGED
@@ -28,17 +28,21 @@ function defaultFormatDate(date) {
28
28
  function createVersionInjector(options = {}) {
29
29
  var _a, _b;
30
30
  const version = (_a = options.version) != null ? _a : getPackageVersion();
31
- ((_b = options.formatDate) != null ? _b : defaultFormatDate)(/* @__PURE__ */ new Date());
31
+ const buildTime = ((_b = options.formatDate) != null ? _b : defaultFormatDate)(/* @__PURE__ */ new Date());
32
32
  const metaTag = `<meta name="version" content="${version}">
33
33
  `;
34
- const logScript = `<script data-injected="unplugin-version-injector">console.log(...)</script>`;
34
+ const logScript = `
35
+ <script data-injected="unplugin-version-injector">
36
+ console.log("%c Version: ${version} ", "background: #222; color: #00ff00; font-size: 12px; padding: 4px; border-radius: 4px;");
37
+ console.log("%c Build Time: ${buildTime} ", "background: #222; color: #ffcc00; font-size: 12px; padding: 4px; border-radius: 4px;");
38
+ </script>`;
35
39
  return function processHtml(html) {
36
40
  if (!html.includes('<meta name="version"')) {
37
- html = html.replace(/<head>/, `<head>
41
+ html = html.replace(/<head>/i, `<head>
38
42
  ${metaTag}`);
39
43
  }
40
- if (!html.includes('<script data-injected="unplugin-version-injector"')) {
41
- html = html.replace("</body>", ` ${logScript}
44
+ if (options.log !== false && !html.includes('data-injected="unplugin-version-injector"')) {
45
+ html = html.replace(/<\/body>/i, ` ${logScript}
42
46
  </body>`);
43
47
  }
44
48
  return html;
package/dist/vite.js CHANGED
@@ -35,17 +35,21 @@ function defaultFormatDate(date) {
35
35
  function createVersionInjector(options = {}) {
36
36
  var _a, _b;
37
37
  const version = (_a = options.version) != null ? _a : getPackageVersion();
38
- ((_b = options.formatDate) != null ? _b : defaultFormatDate)(/* @__PURE__ */ new Date());
38
+ const buildTime = ((_b = options.formatDate) != null ? _b : defaultFormatDate)(/* @__PURE__ */ new Date());
39
39
  const metaTag = `<meta name="version" content="${version}">
40
40
  `;
41
- const logScript = `<script data-injected="unplugin-version-injector">console.log(...)</script>`;
41
+ const logScript = `
42
+ <script data-injected="unplugin-version-injector">
43
+ console.log("%c Version: ${version} ", "background: #222; color: #00ff00; font-size: 12px; padding: 4px; border-radius: 4px;");
44
+ console.log("%c Build Time: ${buildTime} ", "background: #222; color: #ffcc00; font-size: 12px; padding: 4px; border-radius: 4px;");
45
+ </script>`;
42
46
  return function processHtml(html) {
43
47
  if (!html.includes('<meta name="version"')) {
44
- html = html.replace(/<head>/, `<head>
48
+ html = html.replace(/<head>/i, `<head>
45
49
  ${metaTag}`);
46
50
  }
47
- if (!html.includes('<script data-injected="unplugin-version-injector"')) {
48
- html = html.replace("</body>", ` ${logScript}
51
+ if (options.log !== false && !html.includes('data-injected="unplugin-version-injector"')) {
52
+ html = html.replace(/<\/body>/i, ` ${logScript}
49
53
  </body>`);
50
54
  }
51
55
  return html;
package/dist/vite.mjs CHANGED
@@ -28,17 +28,21 @@ function defaultFormatDate(date) {
28
28
  function createVersionInjector(options = {}) {
29
29
  var _a, _b;
30
30
  const version = (_a = options.version) != null ? _a : getPackageVersion();
31
- ((_b = options.formatDate) != null ? _b : defaultFormatDate)(/* @__PURE__ */ new Date());
31
+ const buildTime = ((_b = options.formatDate) != null ? _b : defaultFormatDate)(/* @__PURE__ */ new Date());
32
32
  const metaTag = `<meta name="version" content="${version}">
33
33
  `;
34
- const logScript = `<script data-injected="unplugin-version-injector">console.log(...)</script>`;
34
+ const logScript = `
35
+ <script data-injected="unplugin-version-injector">
36
+ console.log("%c Version: ${version} ", "background: #222; color: #00ff00; font-size: 12px; padding: 4px; border-radius: 4px;");
37
+ console.log("%c Build Time: ${buildTime} ", "background: #222; color: #ffcc00; font-size: 12px; padding: 4px; border-radius: 4px;");
38
+ </script>`;
35
39
  return function processHtml(html) {
36
40
  if (!html.includes('<meta name="version"')) {
37
- html = html.replace(/<head>/, `<head>
41
+ html = html.replace(/<head>/i, `<head>
38
42
  ${metaTag}`);
39
43
  }
40
- if (!html.includes('<script data-injected="unplugin-version-injector"')) {
41
- html = html.replace("</body>", ` ${logScript}
44
+ if (options.log !== false && !html.includes('data-injected="unplugin-version-injector"')) {
45
+ html = html.replace(/<\/body>/i, ` ${logScript}
42
46
  </body>`);
43
47
  }
44
48
  return html;