I use Laravel Mix to compile and extract component css to single file such as app.css. For example I have a component like this:
<template>
<div class="text"> </div>
<template>
...
<style>
.text{ color: red; }
</style>
In webpack.mix.js is:
mix.autoload({
jquery: ['$', 'window.jQuery','window.$'],
quill: ['window.Quill','Quill']
});
mix.options({
extractVueStyles: 'public/css/app.css',
});
mix.js('resources/assets/js/app.js', 'public/js')
.sourceMaps()
.version();
and I put this code in master..blade.php
<link rel="stylesheet" href="{{ url(mix('/css/app.css')) }}">
But app.css is empty and my component css put in html>head as inline style:
<html>
<head>
...
<style>
.text{ color: red; }
</style>
</head>
...
</html>
What should I do to extract and put all component css in app.css?
Same here, using extractVueStyles just do nothing. Any clues ?
I'm having the same issue as well.
Using extractVueStyles: true just overwrites app.css, and using extractVueStyles: '/path/to/file.css' produces an empty file
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I just tried a fresh install and it seems to work as expected. Of course, after making changes to webpack.mix.js you need to call npm run dev or npm run prod or restart the watch command so that the changes have effect.
Here some examples that worked for me:
Example 1: Put css from components in file vue-components.css
mix.options({
extractVueStyles: 'public/css/vue-components.css'
});
mix.js('resources/js/app.js', 'public/js');
Example 2: Put css from components in file vue-components.css and compile app.scss into app.css
mix.options({
extractVueStyles: 'public/css/vue-components.css'
});
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css');
Example 3: Put css from components into app.css and compile app.scss into app.css
mix.options({
extractVueStyles: true
});
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css');
Most helpful comment
I'm having the same issue as well.
Using
extractVueStyles: truejust overwrites app.css, and usingextractVueStyles: '/path/to/file.css'produces an empty file