@ecopages/postcss-processor 0.2.0-beta.1 → 0.2.0-beta.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecopages/postcss-processor",
3
- "version": "0.2.0-beta.1",
3
+ "version": "0.2.0-beta.3",
4
4
  "description": "Postcss processor, transform string or postcss file to css",
5
5
  "keywords": [
6
6
  "postcss",
@@ -17,7 +17,7 @@
17
17
  "directory": "packages/processors/postcss-processor"
18
18
  },
19
19
  "dependencies": {
20
- "@ecopages/file-system": "0.2.0-beta.1",
20
+ "@ecopages/file-system": "0.2.0-beta.3",
21
21
  "@ecopages/logger": "^0.2.3",
22
22
  "autoprefixer": "^10.5.0",
23
23
  "browserslist": "^4.28.2",
@@ -27,7 +27,7 @@
27
27
  "postcss-nested": "^7.0.2"
28
28
  },
29
29
  "peerDependencies": {
30
- "@ecopages/core": "0.2.0-beta.1",
30
+ "@ecopages/core": "0.2.0-beta.3",
31
31
  "@tailwindcss/postcss": ">=4",
32
32
  "tailwindcss": ">=3"
33
33
  },
package/src/plugin.js CHANGED
@@ -64,11 +64,7 @@ class PostCssProcessorPlugin extends Processor {
64
64
  }
65
65
  this.trackedCssFiles.add(filePath);
66
66
  const rawContents = await fileSystem.readFile(filePath);
67
- let transformedInput = rawContents;
68
- if (this.options?.transformInput) {
69
- transformedInput = await this.options.transformInput(rawContents, filePath);
70
- }
71
- const processed = await this.process(transformedInput, filePath);
67
+ const processed = await this.process(rawContents, filePath);
72
68
  this.runtimeCssCache.set(filePath, processed);
73
69
  await this.persistProcessedCss(filePath, processed);
74
70
  }
@@ -151,11 +147,7 @@ class PostCssProcessorPlugin extends Processor {
151
147
  }
152
148
  async transformCssAsync(input) {
153
149
  const { contents, filePath } = input;
154
- let transformed = typeof contents === "string" ? contents : contents.toString("utf-8");
155
- if (this.options?.transformInput) {
156
- const result = this.options.transformInput(contents, filePath);
157
- transformed = typeof result.then === "function" ? await result : result;
158
- }
150
+ const transformed = typeof contents === "string" ? contents : contents.toString("utf-8");
159
151
  const processed = await this.process(transformed, filePath);
160
152
  this.runtimeCssCache.set(filePath, processed);
161
153
  await this.persistProcessedCss(filePath, processed);
@@ -305,10 +297,7 @@ class PostCssProcessorPlugin extends Processor {
305
297
  if (refreshPlugins) {
306
298
  this.refreshConfiguredPlugins();
307
299
  }
308
- let content = await fileSystem.readFile(filePath);
309
- if (this.options?.transformInput) {
310
- content = await this.options.transformInput(content, filePath);
311
- }
300
+ const content = await fileSystem.readFile(filePath);
312
301
  const processed = await this.process(content, filePath);
313
302
  const cached = this.runtimeCssCache.get(filePath);
314
303
  if (cached === processed) {
@@ -39,16 +39,15 @@ function tailwindV4Preset(options) {
39
39
  if (/^\s*@reference\s+/m.test(css)) {
40
40
  return css;
41
41
  }
42
- const relativePath = path.relative(path.dirname(filePath), referencePath);
43
- if (css.includes(`@import '${relativePath}'`) || css.includes(`@import "${relativePath}"`)) {
42
+ if (css.includes(`@import '${normalizedReferencePath}'`) || css.includes(`@import "${normalizedReferencePath}"`)) {
44
43
  return css;
45
44
  }
46
45
  const tailwindImportPattern = /^@import\s+['"]tailwindcss(?:\/[^'"]*)?['"];?\s*$/m;
47
46
  if (tailwindImportPattern.test(css)) {
48
- return css.replace(tailwindImportPattern, `@import '${relativePath}';`);
47
+ return css.replace(tailwindImportPattern, `@import '${normalizedReferencePath}';`);
49
48
  }
50
49
  if (css.includes("@apply")) {
51
- return `@reference "${relativePath}";
50
+ return `@reference "${normalizedReferencePath}";
52
51
 
53
52
  ${css}`;
54
53
  }