mrodal / vue-inheritance-loader

Webpack loader to be used along with vue-loader for Single File Components that provides template extension
38 stars 5 forks source link

Support for absolute paths #6

Closed knorke132 closed 5 years ago

knorke132 commented 5 years ago

If your inheriting component is deeply nested inside your folder structure you may end up with an 'extends' statement looking like this:

<template extends="../../../../../../BaseComponents.vue">

which will break if you now move the child.

The BaseComponent should be accessable with an absolute path beginning from the root e.g.: @/Widgets/BaseComponent.vue where '@/' points to 'src/'

innocenzi commented 5 years ago

I second this. I have an alias @ in Encore which leads to the root, it would be great if I could use it. Maybe using urlToRequest would help? Just a guess, I've never written a webpack loader.

I think the issues is around these lines : https://github.com/mrodal/vue-inheritance-loader/blob/a6b5db83552547740cf169fe6cab137cb2841bf9/src/index.js#L77-L79

mrodal commented 5 years ago

Sorry for taking so long to answer. When @knorke132 first posted I made a fix for this, but didnt uploaded it because it didnt work with the jest extension, since jest doesnt use the webpack aliases.. so the user should define the aliases both in webpack and jest.

I'll try to make it work with jest too and post here any updates

mrodal commented 5 years ago

I've uploaded a version on master, would you care to try it before I publish a new npm version?

Also, do any of you use this together with jest?

xingtianyoulong commented 5 years ago

@mrodal ,your job is very cool for Vue template extends, please publish this with a new npm version now. I use this successfully in nuxt,please publish lastest version include absolute @.

By the way,Is it true that we can not find any other official solution for Vue template extends function except your plugin?

mrodal commented 5 years ago

Well, it took me a long time but it's here, the new version is published (v0.1.7) please let me know if you encounter any problems!