@tailwindcss/postcss 0.0.0-development.1 → 0.0.0-development.2

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/index.d.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import { PluginCreator } from 'postcss';
2
2
 
3
3
  interface PluginOptions {
4
+ /**
5
+ * The directory to scan for Tailwind CSS files.
6
+ * Defaults to the current working directory.
7
+ */
8
+ base?: string;
4
9
  }
5
10
  declare const _default: PluginCreator<PluginOptions>;
6
11
 
package/dist/index.js CHANGED
@@ -1,20 +1,24 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/index.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/index.ts
2
+ var _oxide = require('@tailwindcss/oxide');
2
3
  require('postcss');
3
4
  var _tailwindcss = require('tailwindcss');
4
- var _oxide = require('@tailwindcss/oxide');
5
- function tailwindcss(opts) {
5
+ function tailwindcss(opts = {}) {
6
+ let base = _nullishCoalesce(opts.base, () => ( process.cwd()));
6
7
  return {
7
8
  postcssPlugin: "tailwindcss-v4",
8
9
  AtRule: {
10
+ import: async (atRule, { AtRule }) => {
11
+ let isTailwind = atRule.params === "'tailwindcss'" || atRule.params === '"tailwindcss"';
12
+ if (!isTailwind)
13
+ return;
14
+ atRule.replaceWith(new AtRule({ name: "tailwind" }));
15
+ },
16
+ // We must handle `@tailwind` because not all tools preserve `@import`
17
+ // at-rules and replace them with their content before we see them.
9
18
  tailwind: async (atRule, { result, postcss }) => {
10
- console.time("Tailwind CSS");
11
- console.time("Resolve project");
12
- let project = _oxide.resolveProject.call(void 0, { base: process.cwd() });
13
- console.timeEnd("Resolve project");
14
- console.time("Compile CSS");
15
- let css = _tailwindcss.preflight + _tailwindcss.compile.call(void 0, project.candidates);
16
- console.timeEnd("Compile CSS");
17
- for (let file of project.files) {
19
+ let scanResult = _oxide.scanDir.call(void 0, { base, globs: true });
20
+ let css = _tailwindcss.optimizeCss.call(void 0, _tailwindcss.preflight + _tailwindcss.compile.call(void 0, scanResult.candidates));
21
+ for (let file of scanResult.files) {
18
22
  result.messages.push({
19
23
  type: "dependency",
20
24
  plugin: "tailwindcss-v4",
@@ -22,20 +26,19 @@ function tailwindcss(opts) {
22
26
  parent: result.opts.from
23
27
  });
24
28
  }
25
- for (let { base, glob } of project.globs) {
29
+ for (let { base: base2, glob } of scanResult.globs) {
26
30
  result.messages.push({
27
31
  type: "dir-dependency",
28
32
  plugin: "tailwindcss-v4",
29
- dir: base,
33
+ dir: base2,
30
34
  glob,
31
35
  parent: result.opts.from
32
36
  });
33
37
  }
34
38
  console.time("Parsing CSS");
35
- let result2 = postcss.parse(css);
39
+ let nodes = postcss.parse(css);
36
40
  console.timeEnd("Parsing CSS");
37
- atRule.replaceWith(result2);
38
- console.timeEnd("Tailwind CSS");
41
+ atRule.replaceWith(nodes);
39
42
  }
40
43
  }
41
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailwindcss/postcss",
3
- "version": "0.0.0-development.1",
3
+ "version": "0.0.0-development.2",
4
4
  "scripts": {
5
5
  "build": "tsup-node ./src/index.ts --format cjs --dts --cjsInterop --splitting",
6
6
  "dev": "npm run build -- --watch"
@@ -15,7 +15,7 @@
15
15
  }
16
16
  },
17
17
  "dependencies": {
18
- "tailwindcss": "0.0.0-development.1",
19
- "@tailwindcss/oxide": "0.0.0-development.1"
18
+ "tailwindcss": "0.0.0-development.2",
19
+ "@tailwindcss/oxide": "0.0.0-development.2"
20
20
  }
21
21
  }