Skip to content

Looping recompile with version 4 using laravel Mix #16151

Closed
@cercos

Description

@cercos

When I run "mix watch" it will cause a looping recompile. I am unsure if the issue is with Mix or Tailwind because there's not much info other than a successful compile. I've tried adding ignore paths and different options but always results in a loop. Below is my current file structure. Not sure if there's some other option I need now with version 4 that I may be missing.

style.scss
@use "tailwindcss";

tailwind.config.js

module.exports = {
    content: [
        './resources/**/*.{html,js,scss,css}',
        './templates/**/*.html',
        './resources/**/*.vue',
        './resources/**/*.jsx',
    ],
    theme: {
        extend: {},
    },
    plugins: [],
};

postcss.config.js

module.exports = {
  plugins: [
    [
      "@tailwindcss/postcss",
    ],
  ],
};

webpack.mix.js

const mix = require('laravel-mix');
const path = require('path');

// Compile JavaScript and SCSS
mix.js('resources/js/app.js', 'storage/compiled/js')
    .sass('resources/scss/style.scss', 'storage/compiled/css')
    .options({
        processCssUrls: false, // Prevent CSS URL reprocessing to avoid path issues
        postCss: [
            require('autoprefixer'),
        ],
    });

// Set public path
mix.setPublicPath(".");

// Create alias for cleaner imports
mix.alias({
    "@": path.resolve("resources/js/"),
});

// Handle webfonts and other assets
mix.webpackConfig({
    module: {
        rules: [
            {
                test: /\.(woff2?|eot|ttf|otf|svg)$/, // Match font and SVG files
                type: 'asset/resource', // Handle fonts as resources
                generator: {
                    filename: 'storage/compiled/fonts/[name][ext]', // Output fonts to the compiled storage path
                },
            },
        ],
    },
});

// Copy FontAwesome webfonts to the correct directory to avoid errors
mix.copy(
    'node_modules/@fortawesome/fontawesome-free/webfonts',
    'storage/compiled/fonts'
);

// Versioning for production builds
if (mix.inProduction()) {
    mix.version();
}

// Disable compilation success notification
mix.disableSuccessNotifications();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions