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.

Watch doesn't deliver changes when using Sass and Tailwind

See original GitHub issue
  • Laravel Mix Version: 6.0.39 (npm list --depth=0)
  • Node Version (node -v): 17.0.1
  • NPM Version (npm -v): 8.1.0
  • OS: macOS Monterey v12.1

Description:

Hi, I’m using Laravel Mix with Tailwind 3.0.7.

This is mine webpack.mix.js file:

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

mix
  .setPublicPath('dist')
  .browserSync({
    proxy: "http://localhost:10004",
    files: [
      'dist/**/**',
      'resources/**/**',
      '**/*.php',
    ],
  });

mix
  .js('resources/scripts/app.js', 'js')
  .js('resources/scripts/admin.js', 'js')
  .js('resources/scripts/tinymce-buttons.js', 'js')
  .autoload({
    jquery: [
      '$',
      'window.jQuery',
    ],
  });

mix
  .sass('resources/styles/app.scss', 'css')
  .sass('resources/styles/admin.scss', 'css')
  .sass('resources/styles/editor.scss', 'css');

mix
  .options({
    processCssUrls: false,
    postCss:        [
      tailwindcss('./tailwind.config.js'),
    ],
  });

mix
  .copy('resources/images', 'dist/images')
  .copy('resources/fonts', 'dist/fonts');

mix
  .version()
  .sourceMaps();

This is the content of tailwind.config.js file:

module.exports = {
  mode:    'jit',
  content: [
    './**/*.php',
    './resources/scripts/*.js',
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

Steps To Reproduce:

Everything works fine except watch. If I use commands npx mix build or npx mix --production it builds properly everything. But if I use npx mix watch it starts server with port 8000 and it reloads page properly after I make some change but build is not fresh. Not only that it doesn’t compile changes on Tailwind classes but also other changes in my scss files. Basically it always delivers old files created after last npx mix build.

If I remove this part

    postCss:        [
      tailwindcss('./tailwind.config.js'),
    ],

then all changes in scss files are properly compiled when using npx mix watch.

Did anyone had some problems like these? Am I doing something wrong?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
florianbouvotcommented, Jan 3, 2022
0reactions
JBraddockmcommented, Jan 9, 2022

I am aware of that specific issue. I don’t have it in my project so I can’t comment on it. However, I can see that scss files are not added to JIT watch in OP’s tailwind config, which is something I also experienced when I added files and folders to my projects but forgot to update the config file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Watch doesn't deliver changes when using Sass and Tailwind
Description: Hi, I'm using Laravel Mix with Tailwind 3.0.7. This is mine webpack.mix.js file: const mix = require('laravel ...
Read more >
Watch doesn't deliver changes when using Sass and Tailwind
Hi, I'm using Laravel Mix with Tailwind 3.0.7. This is mine webpack.mix.js file: const mix = require(' ...
Read more >
Using with Preprocessors - Tailwind CSS
A guide to using Tailwind with common CSS preprocessors like Sass, Less, and Stylus.
Read more >
Sass, SCSS, and Less | PyCharm Documentation - JetBrains
PyCharm integrates with compilers that translate Sass, Less, and SCSS code into CSS. ... Change the action that triggers the File Watcher.
Read more >
Laravel doesn't load Tailwind styles - Laracasts
warn - The content option in your Tailwind CSS configuration is missing or empty. warn - Configure your content sources or your generated...
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