rsbuild-plugin-tailwindcss icon indicating copy to clipboard operation
rsbuild-plugin-tailwindcss copied to clipboard

[Feature] Tailwind CSS V2 Support

Open colinaaa opened this issue 1 year ago • 5 comments

Support using this plugin with both tailwindcss@v3 and tailwindcss@v2.

colinaaa avatar Nov 10 '24 06:11 colinaaa

Pending on https://github.com/web-infra-dev/rslib/issues/413

colinaaa avatar Nov 12 '24 14:11 colinaaa

👀 Does this issue rely on https://github.com/web-infra-dev/rslib/issues/413 to build this package itself?

fi3ework avatar Nov 13 '24 03:11 fi3ework

Yes, I'm going to check tailwindcss/package.json#version and use a different Rspack plugin for Tailwind CSS V2. And currently this will give an error since Rslib removes the Import Attributes.

But there is another way to support Tailwind CSS V2. By publishing a different version of this plugin for Tailwind CSS V2.

colinaaa avatar Nov 13 '24 05:11 colinaaa

How about using fs and require.resovle to read tailwindcss/package.json?

chenjiahan avatar Nov 13 '24 05:11 chenjiahan

Yeah, we should go this way. I just checked that Import Attributes is not supported in NodeJS 16 :)

> import('./package.json', { with: {type: 'json'} })
Promise {
  <pending>,
  [Symbol(async_id_symbol)]: 255,
  [Symbol(trigger_async_id_symbol)]: 5
}
> Uncaught:
TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "file:///root/package.json" needs an import assertion of type "json"
    at __node_internal_captureLargerStackTrace (node:internal/errors:478:5)
    at new NodeError (node:internal/errors:387:5)
    at validateAssertions (node:internal/modules/esm/assert:82:15)
    at defaultLoad (node:internal/modules/esm/load:84:3)
    at nextLoad (node:internal/modules/esm/loader:163:28)
    at ESMLoader.load (node:internal/modules/esm/loader:605:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
    at new ModuleJob (node:internal/modules/esm/module_job:63:26)
    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:480:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:438:15) {
  code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING'
}
> process.version
'v16.20.0'

colinaaa avatar Nov 13 '24 08:11 colinaaa