Skip to content

Commit f32f953

Browse files
authored
fix: should allow chaining with loaders for non-vue files (#1889)
Fixes #1879 Fixes #1883 Fixes #1890
1 parent 820d23c commit f32f953

File tree

5 files changed

+34
-12
lines changed

5 files changed

+34
-12
lines changed

src/index.ts

-6
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ export default function loader(
5151
) {
5252
const loaderContext = this
5353

54-
if (!/\.vue(\.html)?$/.test(loaderContext.resourcePath)) {
55-
// ts-loader does some really weird stuff which causes vue-loader to
56-
// somehow be applied on non-vue files... ignore them
57-
return source
58-
}
59-
6054
// check if plugin is installed
6155
if (
6256
!errorEmitted &&

src/templateLoader.ts

-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ const TemplateLoader: webpack.loader.Loader = function (source, inMap) {
1616
source = String(source)
1717
const loaderContext = this
1818

19-
if (/\.[jt]sx?$/.test(loaderContext.resourcePath)) {
20-
// ts-loader does some really weird stuff which causes vue-loader to
21-
// somehow be applied on non-vue files... ignore them
22-
return source
23-
}
24-
2519
// although this is not the main vue-loader, we can get access to the same
2620
// vue-loader options because we've set an ident in the plugin and used that
2721
// ident to create the request for this loader in the pitcher.
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<template>
2+
<div>
3+
<CustomFile />
4+
</div>
5+
</template>
6+
<script>
7+
import CustomFile from './custom-file.svg'
8+
export default {
9+
components: {
10+
CustomFile
11+
}
12+
}
13+
</script>

test/template.spec.ts

+18
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,21 @@ test('postLoaders support', async () => {
102102
// class="red" -> class="green"
103103
expect(instance.$el.className).toBe('green')
104104
})
105+
106+
// #1879
107+
test('should allow process custom file', async () => {
108+
const { instance } = await mockBundleAndRun({
109+
entry: 'process-custom-file/process-custom-file.vue',
110+
module: {
111+
rules: [
112+
{
113+
test: /\.svg$/,
114+
loader: 'vue-loader',
115+
},
116+
],
117+
},
118+
})
119+
120+
expect(instance.$el.tagName).toBe('DIV')
121+
expect(instance.$el.innerHTML).toMatch('ProcessedCustomFile')
122+
})

0 commit comments

Comments
 (0)