Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vue-style-loader for shadowMode #2725

Closed
SergkeiM opened this issue Dec 30, 2020 · 0 comments · Fixed by #2727
Closed

Add vue-style-loader for shadowMode #2725

SergkeiM opened this issue Dec 30, 2020 · 0 comments · Fixed by #2727

Comments

@SergkeiM
Copy link

SergkeiM commented Dec 30, 2020

  • Laravel Mix Version: 6.0.5
  • Node Version: v12.14.1
  • NPM Version: 6.13.4
  • OS: Windows10

Description:

Based on this

With new version we can pass .vue({ options }), 1 of the options of vue-loader is shadowMode, but shadowMode doesn't work without vue-style-loader.

It is possible to add option to change default style-loader to vue-style-loader, I was thinking something like this:

// config.js

...
shadowMode: false,
...
// components/CssWebpackConfig.js

static afterLoaders({ method = 'auto' } = {}) {
    const loaders = [];

    if (Config.shadowMode) {
        loaders.push({
            loader: 'vue-style-loader',
            options: {
                shadowMode: true
            }
        });

        return loaders;
    }

    if (method === 'auto') {
        // TODO: Fix
        if (Mix.extractingStyles !== false) {
            method = 'extract';
        } else {
            method = 'inline';
        }
    }

    if (method === 'inline') {
        loaders.push({ loader: 'style-loader' });
    } else if (method === 'extract') {
        loaders.push({
            loader: MiniCssExtractPlugin.loader,
            options: {
                esModule: true
            }
        });
    } else {
        throw new Error(
            `Unknown css loader method '${method}'. Expected auto, inline, or extract.`
        );
    }

    return loaders;
}
//mixFile
mix.options({
	shadowMode: true
});

mix.js('src/index.js', 'dist/app.js').vue({
	version: 2,
	options: {
		shadowMode: true
	}
});

Ofcourse it will be more correct to use the .vue({ options }), but I couldn't find how I can access vue options in components/CssWebpackConfig.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant