diff --git a/src/pluginWebpack4.ts b/src/pluginWebpack4.ts index 335a6a0a..3745fad6 100644 --- a/src/pluginWebpack4.ts +++ b/src/pluginWebpack4.ts @@ -86,7 +86,10 @@ class VueLoaderPlugin { const parsed = qs.parse(query.slice(1)) return parsed.vue != null && parsed.type === 'template' }, - options: vueLoaderOptions, + options: { + ident: vueLoaderUse.ident, + ...vueLoaderOptions, + }, } // for each rule that matches plain .js/.ts files, also create a clone and diff --git a/test/edgeCases.spec.ts b/test/edgeCases.spec.ts index a0c5aadf..fe89df2a 100644 --- a/test/edgeCases.spec.ts +++ b/test/edgeCases.spec.ts @@ -239,3 +239,30 @@ test('should work with i18n loader in production mode', async () => { expect(result.componentModule.__i18n).toHaveLength(1) }) + +// #2029 +test('should pass correct options to template compiler', async () => { + const fakeCompiler: any = { + compile: jest + .fn() + .mockReturnValue({ code: 'export function render() { return null; }' }), + } + + await mockBundleAndRun({ + entry: 'basic.vue', + modify: (config: any) => { + config.module.rules[0].options = { + compiler: fakeCompiler, + } + config.module.rules.push( + ...Array.from({ length: 10 }).map((_, i) => ({ + test: new RegExp(`\.dummy${i}`), + loader: 'null-loader', + options: { dummyRule: i }, + })) + ) + }, + }) + + expect(fakeCompiler.compile).toHaveBeenCalledTimes(1) +})