ktsn/vue-cli-plugin-auto-routing

<route-meta> loader

rozklad opened this issue ยท 15 comments

Hi,

i really love your plugin for vue cli. There's one thing i've noticed when using <route-meta> custom block.

When using this custom block, it logically does not have loader registered for it so it throws error such as:

Module parse failed: Unexpected token
You may need an appropriate loader to handle this file type.

I came up with a dirty workaround, basically passing the <route-meta> to a custom loader that does not do anything, like this:

# vue.config.js
module.exports = {
  chainWebpack: config => {
    config.module
      .rule('routeMeta')
      .resourceQuery(/blockType=route-meta/)
      .type('javascript/auto')
      .use('routeMeta')
      .loader('routemeta.js');
  }
}

Did i miss something in the installation? Is there a cleaner way to handle this?

ktsn commented

This is because vue-loader always load custom blocks as JS content even if there are no corresponding loaders. I guess this is an issue of vue-loader.

Hello,
First of all, this is absolutely amazing plugin but I still struggling to fix this issue! Is there any new updates?
Thanks a lot

Is there any chance that this could be moved from the <route-meta> element to the component properties (like that of the layout). I.e.

<script>
    export default {
        name: 'about',
        layout: 'auth',
        route_meta: { auth: true }
    }
</script>

I feel this would look and handle much nicer.

ktsn commented

The reason of <route-meta> is described here. ktsn/vue-route-generator#1 (comment)

ktsn commented

This should be fixed in vue-loader v15.6.3.

I have vue-loader 15.7.1 and I still get this error. I also tried above and still got the error.

I too am on vue-loader 15.7.1 and I still get this error - is there any additional info?

On 15.7.2 myself and am running into the same problem

Also

kbhh commented

also

Any ETA for a fix?

@ktsn - that's in the CLI, not in the normal package - I cannot use the CLI variant because I'm using Laravel-Mix

I get this is the wrong repo, but I'm getting ponged from repo to repo ๐Ÿ˜‚

ktsn commented

Then you can add dummy loader by yourself as OP stated.

I tried, didn't fix it... maybe Laravel-Mix isn't taking my loader into account even...