-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Struggling to add TailwindCss #32
Comments
Hey mate, could you share your |
Here are their docs: https://tailwindcss.com/docs/installation/ |
Are there any updates on this issue? I greatly appreciate any info or resources that could point me in the right direction to get this functioning properly. |
I've tried tweaking the presets file based on this thread for a quick/dirty fix, but no luck. Maybe someone else can try who's a bit smarter than I: #14 |
Appreciate the effort and response. Will respond if I find a solution. |
I also would like to use TailwindCSS but haven't found a simple way to add it to the project. @estrattonbailey hope you can help when you find a little while ;) |
Has there been any movement on this issue? |
I ran into this issue yesterday and also couldn't work out a way of adding it. Although, I think this forms part of a larger question about how assets should be handled in the future, and if it's worth revisiting options, since Slater is a relatively new project. With Tailwind, for example, you ideally need to run Purge CSS to reduce the bundle size. All of the additional dependencies and nuances of having a totally extendable Webpack config could potentially be a bit of a support and documentation burden. It might be easier to go with something like Laravel Mix, as it's actively developed, documented, and covers 80% of common use cases. If not, another option would be the ability to add plugins to the underlying Webpack config and to be able to adjust settings from slater.config.js. Again, while this should be possible, it means every config file has the ability to be different, making support more difficult. |
@jack-pallot Definitely some good points. I guess what it boils down to from my perspective is if Slater is going to be oriented at PostCSS life (which it is) then shouldn't there at least be support for (what seems like) a common feature? I say this from camp SASS as I've only very recently begun looking at what PostCSS life looks like and how it can be leveraged. I'm currently using Slater in SASS mode since it just works better and can support the features necessary for building large-scale themes. However the utility based style of Tailwind and similar frameworks/methodologies is very appealing, especially from a maintenance perspective when you're dealing with multiple themes. |
Hey all, understand the frustration here. I'm a functional CSS person myself, and I've heard great things about Tailwind. The main problem here is as @jack-pallot says: Tailwind appears to require some extra config. Another important thing to bring up is that the I started down the path of "plugins" (called The real short-term solution here is to dig into the code and learn how the Webpack config is modified. Have a look at the default PostCSS preset to understand. For Tailwind, I imagine someone could copy that file and extend it with Tailwind config. Then it would be as easy as adding to the Slater config file:
Open to any and all PRs :) |
I'm happy to take a look at getting a preset setup for Tailwind, no promises though, I'll see what I can do. |
Thanks for the info @estrattonbailey! I'm happy to dig into it as well if I can get some time, I definitely love working with Slater. |
Has anyone had any luck with this so far? I found this repo (shopify-tailwind-vue) and tried to replicate it but couldn't manage to make it work. |
@rafaelderolez from my end, due to project priorities I moved back to working from Slate v1, which actually is super easy to add Tailwind to with ~ 5 lines in the config. |
I spent quite a while trying to add a new preset but ultimately couldn't get it to work. I ended up writing a sass equivalent of utilities instead which will work for this particular project. I might revisit at some point because I'm planning to add Purge CSS to my build, but I can't guarantee I'll get any further with it. |
Hey all. Understand the troubles, this isn't easy stuff to configure, let alone configure inside a monorepo like this. Try this. From a slater initialized theme (if you don't have one, run
Then in your module.exports = {
// ... normal config
assets: {
presets: [ 'tailwind' ]
}
} For those curious, this is what the preset looks like. Edit: for visibility, CC @tomaszbujnowicz @jack-pallot @curiouscrusher @rafaelderolez @fowlercraig ✌️ |
I couldn't make that work together - probably made some mistake somewhere. Anyway, wanted to have more control over TailwindCSS and PurgeCSS integration. https://github.com/tomaszbujnowicz/shopify-slater-tailwindcss I know that it probably doesn't really make sense in the long run but needed to have the TailwindCSS setup ready asap as the new project is on the table. Have fun, maybe someone will find that useful ;) |
@estrattonbailey just get this error after adding |
Looked into this a bit more, and realized that const path = require('path')
const ExtractCSS = require('mini-css-extract-plugin')
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')
function tailwindConf ({ config, watch }) {
config.module.rules.push({
test: /\.css$/,
exclude: /node_modules/,
use: [
ExtractCSS.loader,
require.resolve('css-loader'),
{
loader: require.resolve('postcss-loader'),
options: {
plugins: [
require('postcss-import'),
require('tailwindcss'),
require('postcss-nested'),
require('postcss-preset-env')({
stage: 0
}),
require('autoprefixer')
]
}
}
]
})
config.plugins = config.plugins.concat([
new ExtractCSS({
filename: '[name].css'
}),
watch && new OptimizeCssAssetsPlugin({
cssProcessor: require('cssnano'),
cssProcessorPluginOptions: {
preset: ['default', { discardComments: { removeAll: true } }],
},
})
].filter(Boolean))
return config
}
module.exports = {
themes: {
development: {
id: '...',
password: '...',
store: '....myshopify.com',
ignore: [ 'settings_data.json' ]
}
},
assets: {
presets: [ tailwindConf ]
}
} Remember to In the entry CSS file (or anywhere else) you can then use This creates quite a large CSS file of course, so I add PurgeCSS as a postbuild step. |
@n-kort I have merged this in, anyone else in the tailwind world feel free to let us know if this worked. |
Hi, first, thanks for this awesome tool. I have a question on how to purge tailwindcss on a production build. After I run |
@qiandongyq easiest is just to use the
|
@qiandongyq - I recommend adding:
To @n-kort 's purge settings as that's helped with Shopify themes I've used Tailwind on. |
@n-kort Would you mind demonstrating how you're including purgecss? |
@fowlercraig definitely simplest to use the above in your Tailwind config, but basically the same settings work in a
The config file looks something like module.exports = {
defaultExtractor: content => content.match(/[\w-/:]+(?<!:)/g) || [],
content: [
'./build/**/*.liquid',
'./build/assets/*.js'
],
css: [
'./build/assets/*.css'
],
whitelistPatterns: []
} |
I LOVE YOU @n-kort. Been beating my head against a wall all day getting Tailwind working and this was the ticket. I owe you a beer! |
Following the directions in the Tailwind docs, I’ve tried adding the plugin declarations in slater.config.js, but it’s failing to compile properly.
It’s not throwing any errors, so I’m a little confused what’s going wrong.
The text was updated successfully, but these errors were encountered: