abo*_*sem 3 javascript reactjs tailwind-css craco
一切工作正常npm start (craco start),颜色正在编译。
但运行时npm run build (craco build),每个配置仅编译一种颜色,dallas来自theme.textColor和vista-white来自theme.gradientColorStops。
我试过:
theme.textColor属性。node_modules和npm i.build并重建。// craco.config.js
module.exports = {
style: {
postcss: {
plugins: [require('tailwindcss'), require('autoprefixer')],
},
},
};
Run Code Online (Sandbox Code Playgroud)
// tailwind.config.js
module.exports = {
purge: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
textColor: (theme) => ({
...theme('colors'),
dallas: '#664A2D',
'blue-charcoal': '#24292E',
denim: '#0D66C2',
'spring-green': '#05E776',
flamingo: '#E65A4D',
}),
gradientColorStops: (theme) => ({
...theme('colors'),
'vista-white': '#E1DFDC',
}),
},
variants: {
extend: {},
},
plugins: [],
};
Run Code Online (Sandbox Code Playgroud)
abo*_*sem 10
感谢@George指出问题:
Purge 不会识别您对此类的使用。请参阅https://tailwindcss.com/docs/optimizing-for-Production#writing-purgeable-html。具体来说,“不要使用字符串连接来创建类名”。清除无论如何都不是“智能”的,它的工作原理是将您的实用程序与整个模板中的类(或任何字符串,实际上......)进行匹配。
一种可能的解决方案是将要清除的类添加到purge.options.safelist:
// tailwind.config.js
module.exports = {
// Added safelist
purge: {
content: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'],
options: {
safelist: ['hover:text-blue-charcoal', 'hover:text-denim', 'hover:text-spring-green', 'hover:text-flamingo'],
},
},
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
textColor: (theme) => ({
...theme('colors'),
dallas: '#664A2D',
'blue-charcoal': '#24292E',
denim: '#0D66C2',
'spring-green': '#05E776',
flamingo: '#E65A4D',
}),
gradientColorStops: (theme) => ({
...theme('colors'),
'vista-white': '#E1DFDC',
}),
},
variants: {
extend: {},
},
plugins: [],
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10075 次 |
| 最近记录: |