grunt-purgecss 8.0.0 → 9.0.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/package.json +12 -10
  2. package/tasks/purgecss.js +10 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grunt-purgecss",
3
- "version": "8.0.0",
3
+ "version": "9.0.0",
4
4
  "description": "Grunt plugin for PurgeCSS",
5
5
  "author": "Ffloriel",
6
6
  "homepage": "https://purgecss.com",
@@ -17,6 +17,9 @@
17
17
  "purify"
18
18
  ],
19
19
  "license": "MIT",
20
+ "engines": {
21
+ "node": ">=22.12.0"
22
+ },
20
23
  "types": "./tasks/purgecss.d.ts",
21
24
  "files": [
22
25
  "tasks"
@@ -26,16 +29,12 @@
26
29
  "url": "git+https://github.com/FullHuman/purgecss.git",
27
30
  "directory": "packages/grunt-purgecss"
28
31
  },
29
- "scripts": {
30
- "build": "ts-node build.ts",
31
- "test": "jest"
32
- },
33
32
  "dependencies": {
34
- "purgecss": "^5.0.0"
33
+ "purgecss": "^9.0.0"
35
34
  },
36
35
  "devDependencies": {
37
- "@types/grunt": "^0.4.25",
38
- "grunt": "~1.6.1"
36
+ "@types/grunt": "^0.4.32",
37
+ "grunt": "^1.6.3"
39
38
  },
40
39
  "bugs": {
41
40
  "url": "https://github.com/FullHuman/purgecss/issues"
@@ -44,5 +43,8 @@
44
43
  "access": "public",
45
44
  "registry": "https://registry.npmjs.org/"
46
45
  },
47
- "gitHead": "9269dbc8b589832bab90d29f5821fc4cf55077d6"
48
- }
46
+ "scripts": {
47
+ "build": "ts-node build.ts",
48
+ "test": "jest"
49
+ }
50
+ }
package/tasks/purgecss.js CHANGED
@@ -19,6 +19,10 @@ function gruntPurgeCSS(grunt) {
19
19
  const promisedPurgedFiles = [];
20
20
  for (const file of this.files) {
21
21
  const source = getAvailableFiles(grunt, file.src);
22
+ if (source.length === 0) {
23
+ promisedPurgedFiles.push(Promise.reject(new Error(`No source files found for "${file.dest}".`)));
24
+ continue;
25
+ }
22
26
  const purgedCss = new purgecss.PurgeCSS()
23
27
  .purge({
24
28
  ...options,
@@ -28,7 +32,8 @@ function gruntPurgeCSS(grunt) {
28
32
  if (typeof file.dest === "undefined") {
29
33
  throw new Error(`Destination file not found`);
30
34
  }
31
- grunt.file.write(file.dest, purgeCSSResults[0].css);
35
+ // PurgeCSS returns one result per source file, so write them all.
36
+ grunt.file.write(file.dest, purgeCSSResults.map((result) => result.css).join("\n"));
32
37
  // Print a success message
33
38
  grunt.log.writeln(`File "${file.dest}" created.`);
34
39
  });
@@ -38,7 +43,10 @@ function gruntPurgeCSS(grunt) {
38
43
  .then(() => {
39
44
  done();
40
45
  })
41
- .catch(() => done(false));
46
+ .catch((error) => {
47
+ grunt.log.error(error.message);
48
+ done(false);
49
+ });
42
50
  });
43
51
  }
44
52