Skip to content
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

CSS styles not being applied - set inject: true for rollup-plugin-postcss #959

Closed
gmencz opened this issue Jan 19, 2021 · 2 comments
Closed
Labels
kind: support Asking for support with something or a specific use case scope: integration Related to an integration, not necessarily to core (but could influence core) solution: duplicate This issue or pull request already exists solution: intended behavior This is not a bug and is expected behavior

Comments

@gmencz
Copy link

gmencz commented Jan 19, 2021

Current Behavior

Tailwind CSS styles not being applied.

Additional context

I'm not sure this is a bug, I think I'm missing something in my config but I don't know what, here's my tsdx.config.js:

const postcss = require('rollup-plugin-postcss');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const tailwindcss = require('tailwindcss');

module.exports = {
  rollup(config, options) {
    config.plugins.push(
      postcss({
        plugins: [
          autoprefixer(),
          tailwindcss(),
          cssnano({
            preset: 'default',
          }),
        ],
        inject: false,
        // only write out CSS for the first bundle (avoids pointless extra files):
        extract: !!options.writeMeta,
      })
    );
    return config;
  },
};

Your environment

System:
    OS: Linux 4.19 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
    Memory: 4.13 GB / 12.44 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
Binaries:
  Node: 14.13.1 - ~/.nvm/versions/node/v14.13.1/bin/node
  npm: 6.14.11 - ~/.nvm/versions/node/v14.13.1/bin/npm
npmPackages:
  typescript: ^3.4.5 => 3.9.7
@agilgur5 agilgur5 added kind: support Asking for support with something or a specific use case solution: duplicate This issue or pull request already exists labels Jan 20, 2021
@agilgur5
Copy link
Collaborator

agilgur5 commented Jan 20, 2021

Tailwind CSS styles not being applied.

You'll have to be a lot more specific by what you mean by "not applied".

Your rollup-plugin-postcss configuration has inject: false and extract: true, meaning it outputs a CSS file. The consumers of your library then have to import the CSS file to get those styles.
It's difficult to tell given the lack of detail here, but I assume you may want the opposite. In which case this would largely be a duplicate of #947 (comment). If so, this isn't a bug and isn't TSDX specific nor Tailwind specific, and is just support with configuring rollup-plugin-postcss.

Your environment

It seems like you may not have ran this in the correct directory as your TSDX version is not specified here (and potentially other issues)

@gmencz
Copy link
Author

gmencz commented Jan 20, 2021

Got it, inject: false was the issue, setting it to true fixed it, thanks for the help.

@gmencz gmencz closed this as completed Jan 20, 2021
@agilgur5 agilgur5 changed the title Tailwind CSS styles not being applied CSS styles not being applied - set inject: true for rollup-plugin-postcss Jan 20, 2021
@agilgur5 agilgur5 added the scope: integration Related to an integration, not necessarily to core (but could influence core) label Mar 4, 2021
@agilgur5 agilgur5 added the solution: intended behavior This is not a bug and is expected behavior label Apr 21, 2021
Repository owner locked as resolved and limited conversation to collaborators Apr 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind: support Asking for support with something or a specific use case scope: integration Related to an integration, not necessarily to core (but could influence core) solution: duplicate This issue or pull request already exists solution: intended behavior This is not a bug and is expected behavior
Projects
None yet
Development

No branches or pull requests

2 participants