diff --git a/index.js b/index.js index d5e7924..895bde9 100644 --- a/index.js +++ b/index.js @@ -32,7 +32,8 @@ const defaultLookups = { '.scss': sassLookup, '.styl': stylusLookup, '.ts': tsLookup, - '.tsx': tsLookup + '.tsx': tsLookup, + '.vue': vueLookup }; /** @@ -389,6 +390,37 @@ function commonJSLookup(options) { return result; } +function vueLookup(options) { + const { dependency } = options; + + if (!dependency) { + debug('blank dependency given. Returning early.'); + return ''; + } + + if (dependency.endsWith('.js') || dependency.endsWith('.jsx')) { + return jsLookup(options); + } + + if (dependency.endsWith('.ts') || dependency.endsWith('.tsx')) { + return tsLookup(options); + } + + if (dependency.endsWith('.scss') || dependency.endsWith('.sass') || dependency.endsWith('.less')) { + return sassLookup(options); + } + + if (dependency.endsWith('.styl')) { + return stylusLookup(options); + } + + if (options.tsConfig || options.tsConfigPath) { + return tsLookup(options); + } + + return jsLookup(options); +} + function resolveWebpackPath({ dependency, filename, directory, webpackConfig }) { if (!webpackResolve) { webpackResolve = require('enhanced-resolve'); diff --git a/test/test.js b/test/test.js index d1254c2..6bca2b5 100644 --- a/test/test.js +++ b/test/test.js @@ -21,7 +21,8 @@ describe('filing-cabinet', () => { '.scss', '.styl', '.ts', - '.tsx' + '.tsx', + '.vue' ].sort(); assert.deepEqual(actual, expected); });