Laravel-mix: How to extract styles from vue components?

Created on 5 Feb 2017  路  3Comments  路  Source: JeffreyWay/laravel-mix

It is obvious that styles written in .vue components should be extracted to separate files. Is there a built-in support or this? In pevious version I've edited config like this:

rules: [
        {
            test: /\.vue$/,
            loader: 'vue-loader',
            options: {
                loaders: {
                    js: 'babel-loader' + Mix.babelConfig(),
                    css: plugins.ExtractTextPlugin.extract({
                        loader: 'css-loader',
                        fallbackLoader: 'vue-style-loader'
                    }),
//

but now this fails with error

Most helpful comment

I've added support for this on master. It'll be tagged at some point this week, likely.

Once tagged, you can turn on Vue style extraction with:

mix.options({ extractVueStyles: true });

All 3 comments

I've added support for this on master. It'll be tagged at some point this week, likely.

Once tagged, you can turn on Vue style extraction with:

mix.options({ extractVueStyles: true });

@JeffreyWay thank you!

@JeffreyWay I'v added your commit to my config and I want to aware you: this makes impossible to use multiple stylesheets.

2017-02-10 00 59 51

2017-02-10 01 00 09

You can see that styles, extracted from two js files (app.js and ui.js) are extracted to both app.css and home.css. And they are similar at the end

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RomainGoncalves picture RomainGoncalves  路  3Comments

Micaso picture Micaso  路  3Comments

Bomavi picture Bomavi  路  3Comments

kpilard picture kpilard  路  3Comments

mementoneli picture mementoneli  路  3Comments