diff --git a/lib/template-compiler/index.js b/lib/template-compiler/index.js index d868bbb44..53bcb4fcc 100644 --- a/lib/template-compiler/index.js +++ b/lib/template-compiler/index.js @@ -23,6 +23,7 @@ module.exports = function (html) { var compilerOptions = { preserveWhitespace: options.preserveWhitespace, modules: defaultModules.concat(userModules || []), + directives: vueOptions.compilerDirectives || options.compilerDirectives || {}, scopeId: options.hasScoped ? options.id : null } diff --git a/test/fixtures/custom-directive.vue b/test/fixtures/custom-directive.vue new file mode 100644 index 000000000..b11d74e33 --- /dev/null +++ b/test/fixtures/custom-directive.vue @@ -0,0 +1,3 @@ + diff --git a/test/test.js b/test/test.js index 369b69906..c972f774a 100644 --- a/test/test.js +++ b/test/test.js @@ -872,6 +872,29 @@ describe('vue-loader', function () { }) }) + it('custom compiler directives', done => { + test({ + entry: './test/fixtures/custom-directive.vue', + vue: { + compilerDirectives: { + i18n (el, dir) { + if (dir.name === 'i18n' && dir.value) { + el.i18n = dir.value + if (!el.props) { + el.props = [] + } + el.props.push({ name: 'textContent', value: `_s(${JSON.stringify(dir.value)})` }) + } + } + } + } + }, (window, module) => { + var vnode = mockRender(module) + expect(vnode.data.domProps.textContent).to.equal('keypath') + done() + }) + }) + it('functional component with styles', done => { test({ entry: './test/fixtures/functional-style.vue'