kevinlang / phx_gen_tailwind

Mix task to add Tailwind CSS to a new Phoenix 1.6+ project
Apache License 2.0
66 stars 5 forks source link

@import seems to have no effect #9

Open benkeil opened 2 years ago

benkeil commented 2 years ago

I updated the postcss.config.js to

module.exports = {
  plugins: {
    'postcss-import': {},
    'tailwindcss/nesting': {},
    tailwindcss: {},
    autoprefixer: {},
  },
}

Created a new css file components.css with

@layer components {
  .h1-alert {
    @apply text-red-500 text-5xl font-bold text-center;
  }
}

and added it to the app.css

@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";
@import "components.css";
...

but the styles get not applied. What I am doing wrong?

benkeil commented 2 years ago

You need to add --postcss to the watchers arguments.

npx: [
  "tailwindcss",
  "--postcss",
  "--input=css/app.css",
  "--output=../priv/static/assets/app.css",
  "--watch",
  cd: Path.expand("../apps/playground_web/assets", __DIR__)
]