Search code examples
csslaravellaravel-mix

laravel generates css after npm run dev


I am working on a project and I have a couple of views.

I am using the included bootstrap from laravel but in the resources/sass/_variables.scss I changed some of the default colors.

After that, I ran npm run dev to recompile.

After that I checked public/css and there were css files for every view that I created.

Is it possible that laravel mix generated these files?

Also, is it possible to edit these without laravel mix overriding your changes?

webpack.mix.js

let mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.react('resources/js/app.js', 'public/js')
   .sass('resources/sass/app.scss', 'public/css');


Solution

  • This is exactly what laravel mix is supposed to do. You shouldn't edit the built css files directly. You can find the app.scss file in resources/sass and edit that or if you, for some reason, want to create a css file directly to your public/css directory you can do that too. If you don't use the same file names, mix won't overwrite your files.