从尾风中的库中添加插件
我正在使用React,NX,Tailwind来创建一个带有多个配置
MonorePo
的 每个项目一个配置 一个扩展每个LIB项目配置的插件。
我目前有以下内容:
root :: tailwind.config
(基本样式)
module.exports = {
content: [],
theme: {
extend: {
colors: {
'27313B': '#27313B',
},
},
},
plugins: [],
};
project :: tailwdind.config
(扩展了root并呼叫插件)
const { createGlobPatternsForDependencies } = require('@nrwl/react/tailwind');
const { join } = require('path');
module.exports = {
content: [
join(__dirname, 'src/**/!(*.stories|*.spec).{ts,tsx,html}'),
...createGlobPatternsForDependencies(__dirname),
],
presets: [require(join(__dirname, '../../tailwind.config'))],
theme: {
extend: {},
},
plugins: [require(join(__dirname, '../../libs//tailwind.plugin'))],
};
lib:lib: :tailwind.plugin
const plugin = require('tailwindcss/plugin');
module.exports = {
plugins: [
plugin(
function ({ matchUtilities, theme }) {
matchUtilities(
{
colors: (value) => ({
colors: value,
}),
},
{ values: theme('colors') }
);
},
{
theme: {
extend: {
colors: {
F00: '#f00',
},
},
},
}
),
],
};
可悲的是,插件永远无法使用,
这样做 < div className = {'text-27313b'}> asdasd</div>
显示好的颜色,但 < div className = {'text-f00'}> asdasd</div>
我不
配置错误吗?
I am using react, nx, tailwind to create a monorepo with multiple config
What I would like to achieve is
one config for the whole repo
one config per project
one plugin that extend the project config on each lib.
I currently have this :
root::tailwind.config
(base styles)
module.exports = {
content: [],
theme: {
extend: {
colors: {
'27313B': '#27313B',
},
},
},
plugins: [],
};
project::tailwdind.config
(extends the root and call for a plugin)
const { createGlobPatternsForDependencies } = require('@nrwl/react/tailwind');
const { join } = require('path');
module.exports = {
content: [
join(__dirname, 'src/**/!(*.stories|*.spec).{ts,tsx,html}'),
...createGlobPatternsForDependencies(__dirname),
],
presets: [require(join(__dirname, '../../tailwind.config'))],
theme: {
extend: {},
},
plugins: [require(join(__dirname, '../../libs//tailwind.plugin'))],
};
lib::tailwind.plugin
const plugin = require('tailwindcss/plugin');
module.exports = {
plugins: [
plugin(
function ({ matchUtilities, theme }) {
matchUtilities(
{
colors: (value) => ({
colors: value,
}),
},
{ values: theme('colors') }
);
},
{
theme: {
extend: {
colors: {
F00: '#f00',
},
},
},
}
),
],
};
Sadly, the plugin never work,
doing<div className={'text-27313B'}>asdasd</div>
show the good color but<div className={'text-F00'}>asdasd</div>
dont
I am configuring it wrong ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你尝试这个
you try this
好的,我复制了错误的粘贴...
工作。
我正在导出一个插件:plugin(),而不是只是插件()
ok I copy pasted wrong...
works.
I was exporting a plugin : plugin() instead of just plugin()