Skip to content

Missing Vue.js style loader then using dev-server with HMR #575

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

Closed
Ovissse opened this issue May 14, 2019 · 5 comments
Closed

Missing Vue.js style loader then using dev-server with HMR #575

Ovissse opened this issue May 14, 2019 · 5 comments

Comments

@Ovissse
Copy link

Ovissse commented May 14, 2019

I noticed that then Vue.js loader is enabled and dev-server is started using --hot the configuration still returns mini-css-extract-plugin loader in sass and css rules.

In Vue.js guide they use vue-style-loader instead of mini-css-extract-plugin then not in production environment

@Ovissse
Copy link
Author

Ovissse commented May 14, 2019

Manually replacing loader seems to solve problem

if (Encore.isDevServer()) {
    Encore.configureLoaderRule('sass', (rule) => {
        if (rule.oneOf) {
            rule.oneOf.map((one, key) => {
                one.use.map((use, useKey) => {
                    if (typeof use === 'string' && /[\\\/]mini\-css\-extract\-plugin[\\\/]/.test(use)) {
                        rule.oneOf[key].use[useKey] = 'vue-style-loader';
                    }
                });
            });
        }
    });
    Encore.configureLoaderRule('css', (rule) => {
        if (rule.oneOf) {
            rule.oneOf.map((one, key) => {
                one.use.map((use, useKey) => {
                    if (typeof use === 'string' && /[\\\/]mini\-css\-extract\-plugin[\\\/]/.test(use)) {
                        rule.oneOf[key].use[useKey] = 'vue-style-loader';
                    }
                });
            });
        }
    });
}

@Kocal
Copy link
Member

Kocal commented May 14, 2019

Maybe #3 will help you

@Ovissse
Copy link
Author

Ovissse commented May 14, 2019

Maybe #3 will help you

Oh it's ongoing topic, as I see there is option to disable mini-css-extract-plugin, but hooking vue-style-loader is still not available at current time

@Lyrkan
Copy link
Collaborator

Lyrkan commented May 16, 2019

Oh it's ongoing topic, as I see there is option to disable mini-css-extract-plugin, but hooking vue-style-loader is still not available at current time

You should be fine by simply calling Encore.disableCssExtraction() when the dev-server is enabled.

The vue-style-loader is only a fork of the style-loader that doesn't add much things if you aren't using SSR and looks less maintained than the former... so I don't see many reasons to use it.

@Ovissse
Copy link
Author

Ovissse commented Jun 5, 2019

Sorry for delayed response, calling disableCssExtraction() works. Seems the vue-loader handles HMR then mini-css-extract-plugin is not used

@Ovissse Ovissse closed this as completed Jun 5, 2019
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

No branches or pull requests

3 participants