question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why was the postcss-import added?

See original GitHub issue

What was the reason the postcss-import plugin was added? seems to be working without it as well.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
vltanskycommented, Dec 27, 2020

@shaharkazaz @nartc I’ve succeeded to make it work according to answers in this issue: https://github.com/angular/angular-cli/issues/8427 As Angular 11.0.5 uses Postcss 8 we don’t need to install PostCSS 8, postcss-import, autoprefixer and etc. as angular already have it.

So after ng add @ngneat/tailwind I’ve removed all node modules that we don’t need anymore:

$ npm uninstall postcss postcss-loader postcss-import autoprefixer postcss-scss -D

and according to https://github.com/angular/angular-cli/issues/8427#issuecomment-742294238 with small modifications changed webpack.config.js to:

module.exports = (config) => {
  const isProd = config.mode === 'production';
  const tailwindConfig = require('./tailwind.config.js')(isProd);

  const globalStylesPostcssLoaderOptions = config.module.rules
    .find((r) => r.include && r.test && r.test.toString().includes('\\.scss$'))
    .use.find((u) => u.loader && u.loader.includes('postcss-loader')).options;

  const globalStylesPostcssOptionsCreator = globalStylesPostcssLoaderOptions.postcssOptions;

  globalStylesPostcssLoaderOptions.postcssOptions = (loader) => {
    const postcssOptions = globalStylesPostcssOptionsCreator(loader);
    postcssOptions.plugins.splice(postcssOptions.plugins.length - 1, 0, require('tailwindcss')(tailwindConfig));

    return postcssOptions;
  };
  return config;
};

Here is a repo to test it: https://github.com/vltansky/tailwind-ng11

In this commit you can see all changes: https://github.com/vltansky/tailwind-ng11/commit/1e58ee15546557ceeb5b35ec33d22c9d84bb9cf0

Now @apply is working and all the imports (e.g ag-grid, ionic) will work too. The only thing to mention, that @apply will work only in global styles, not in components (do we need it on components level? it may slow down builds)

3reactions
shaharkazazcommented, Oct 30, 2020

@nartc Share your findings once you have some 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

PostCSS plugin to inline @import rules content
PostCSS plugin to transform @import rules by inlining content. This plugin can consume local files, node modules or web_modules. To resolve path of...
Read more >
How are `postcss-import` configured plugins applied
It's recommended to make postcss-import the first plugin in your list when you're defining the plugins for postcss in webpack.
Read more >
postcss-import | Yarn - Package Manager
PostCSS plugin to transform @import rules by inlining content. This plugin can consume local files, node modules or web_modules. To resolve path of...
Read more >
What is PostCSS? How to Use Plugins to Automate CSS ...
PostCSS Import. One of the basic and most important plugins to use is postcss-import. It lets us import CSS files into other files....
Read more >
Add support for postcss-import with css in node_modules
As OP mentioned, css-loader explicitly allows you to specify a leading ~ to imply, "look in node_modules". From what I can tell, postcss-loader...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found