vite-plugin-comment-delete 1.0.1 → 1.1.0

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.
Files changed (2) hide show
  1. package/index.js +9 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,5 +1,9 @@
1
1
  import fs from "fs";
2
- import path from "node:path";
2
+ import path from "path";
3
+ import { fileURLToPath } from "url";
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
3
7
 
4
8
  export default function commentDelete() {
5
9
  return {
@@ -17,14 +21,14 @@ export default function commentDelete() {
17
21
  } else if (/\.(html|php)$/.test(file)) {
18
22
  let content = fs.readFileSync(fullPath, "utf-8");
19
23
 
20
- // HTMLコメント削除 <!-- -->
24
+ // HTMLコメント削除
21
25
  content = content.replace(/<!--[\s\S]*?-->/g, "");
22
26
 
23
27
  // PHPコメント削除
24
28
  content = content
25
- .replace(/\/\*[\s\S]*?\*\//g, "") // /* */
26
- .replace(/\/\/.*$/gm, "") // //
27
- .replace(/#.*$/gm, ""); // #
29
+ .replace(/\/\*[\s\S]*?\*\//g, "")
30
+ .replace(/\/\/.*$/gm, "")
31
+ .replace(/#.*$/gm, "");
28
32
 
29
33
  fs.writeFileSync(fullPath, content);
30
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-comment-delete",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Build完了後にdist内に含まれるhtmlとphpのコメントアウトを削除する",
5
5
  "main": "index.js",
6
6
  "keywords": [