Skip to content

Issue 2: Missing PurgeCSS configuration in Production #4

Description

@PrinceSajjadHussain

The tailwind.config.js file defines the content that Tailwind should scan for used classes. However, there is no explicit configuration to ensure that unused CSS is purged during a production build. This can lead to a significantly larger CSS bundle than necessary, impacting page load performance.

To address this, consider using a tool like PurgeCSS or the @tailwindcss/container-queries plugin alongside Tailwind in your build process. This typically involves integrating PurgeCSS within your postcss.config.js file and potentially setting the NODE_ENV environment variable to trigger the purge only during production builds. The following steps are recommended:

  1. Install PurgeCSS: npm install -D @fullhuman/postcss-purgecss

  2. Update postcss.config.js:

    module.exports = {
      plugins: {
        tailwindcss: {},
        autoprefixer: {},
        ...(process.env.NODE_ENV === 'production'
          ? {
              '@fullhuman/postcss-purgecss': {
                content: [
                  './pages/**/*.{js,jsx,ts,tsx}',
                  './components/**/*.{js,jsx,ts,tsx}',
                  './src/**/*.{js,jsx,ts,tsx}',
                  './index.html'
                ],
                defaultExtractor: (content) => content.match(/[\w-/:]+(?<!:)/g) || [],
              },
            }
          : {}),
      },
    };
  3. Adjust content: Ensure the content array in the PurgeCSS config accurately reflects all files containing Tailwind classes.


**Issue 3: Eslint: Consider adding a rule to prevent `console.log` statements in production code.**

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions