Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix: not allow process custom file (fix #1879) #1889

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

Merged
merged 1 commit into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions 6 src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ export default function loader(
) {
const loaderContext = this

if (!/\.vue(\.html)?$/.test(loaderContext.resourcePath)) {
// ts-loader does some really weird stuff which causes vue-loader to
// somehow be applied on non-vue files... ignore them
return source
}

// check if plugin is installed
if (
!errorEmitted &&
Expand Down
6 changes: 0 additions & 6 deletions 6 src/templateLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ const TemplateLoader: webpack.loader.Loader = function (source, inMap) {
source = String(source)
const loaderContext = this

if (/\.[jt]sx?$/.test(loaderContext.resourcePath)) {
// ts-loader does some really weird stuff which causes vue-loader to
// somehow be applied on non-vue files... ignore them
return source
}

// although this is not the main vue-loader, we can get access to the same
// vue-loader options because we've set an ident in the plugin and used that
// ident to create the request for this loader in the pitcher.
Expand Down
3 changes: 3 additions & 0 deletions 3 test/fixtures/process-custom-file/custom-file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions 13 test/fixtures/process-custom-file/process-custom-file.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<template>
<div>
<CustomFile />
</div>
</template>
<script>
import CustomFile from './custom-file.svg'
export default {
components: {
CustomFile
}
}
</script>
18 changes: 18 additions & 0 deletions 18 test/template.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,21 @@ test('postLoaders support', async () => {
// class="red" -> class="green"
expect(instance.$el.className).toBe('green')
})

// #1879
test('should allow process custom file', async () => {
const { instance } = await mockBundleAndRun({
entry: 'process-custom-file/process-custom-file.vue',
module: {
rules: [
{
test: /\.svg$/,
loader: 'vue-loader',
},
],
},
})

expect(instance.$el.tagName).toBe('DIV')
expect(instance.$el.innerHTML).toMatch('ProcessedCustomFile')
})
Morty Proxy This is a proxified and sanitized view of the page, visit original site.