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

Invalid Component Definition #140

Open
aavorthmann opened this issue Oct 12, 2020 · 3 comments
Open

Invalid Component Definition #140

aavorthmann opened this issue Oct 12, 2020 · 3 comments

Comments

@aavorthmann
Copy link

I am trying to use the loader in a Laravel project and I keep getting an error of "Invalid Component Definition: route/filename.svg". I have Laravel Framework ^6.0 and vue@2.6.12 for this project. Any help would be appreciated! These are the rules I have in webpack.mix.js:

module.exports = {

    chainWebpack: (config) => {

        const svgRule = config.module.rule('svg');


        svgRule.uses.clear();


        svgRule

            .use('vue-svg-loader')

            .loader('vue-svg-loader')

            .options({

                svgo: {

                    plugins: [

                        {removeDoctype: true},

                        {removeComments: true},

                        {cleanupIDs: false},

                        {collapseGroups: false},

                        {removeEmptyContainers: false},

                        {removeUnusedNS: false},

                        {prefixIds: false}

                        ],

                },

            });
    
        },

};
@raffobaffo
Copy link

Anybody? Exact same problem here

@pomelo-alias
Copy link

two case:

  1. webpack's version earlier than 5; you can remove svg in file-loader's rule
  2. webpack 5 use Asset Modules type replaces those asset loader; so if you run vue inspect --rule svg will find these is a type in config, which is 'asset/resource'; then you can change it's value to 'javascript/auto'. for more detail you can check https://webpack.js.org/guides/asset-modules/

@adamalfredsson
Copy link

two case:

  1. webpack's version earlier than 5; you can remove svg in file-loader's rule
  2. webpack 5 use Asset Modules type replaces those asset loader; so if you run vue inspect --rule svg will find these is a type in config, which is 'asset/resource'; then you can change it's value to 'javascript/auto'. for more detail you can check https://webpack.js.org/guides/asset-modules/

Thanks! This is a working vue config:

module.exports = {
  chainWebpack: (config) => {
    const svgRule = config.module.rule('svg');
    svgRule.type('javascript/auto');
    svgRule.uses.clear();
    svgRule.use('babel-loader').loader('babel-loader').end().use('vue-svg-loader').loader('vue-svg-loader');
  },
}

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

4 participants