diff --git a/__tests__/index.spec.js b/__tests__/index.spec.js index 8735117..b20a8ba 100644 --- a/__tests__/index.spec.js +++ b/__tests__/index.spec.js @@ -257,10 +257,29 @@ describe('js-to-styles-vars-loader', () => { expect(operator.getPreprocessorType({ resource: '/path/to/resource.sass'})).toEqual('sass'); }); + it('should recognise sass resource in vue inline style', () => { + expect(operator.getPreprocessorType({ resource: '/path/to/resource.vue?vue&type=style&index=0&id=2964abc9&scoped=true&lang=scss&'})).toEqual('sass'); + expect(operator.getPreprocessorType({ resource: '/path/to/resource.vue?vue&type=style&index=0&id=2964abc9&scoped=true&lang=sass&'})).toEqual('sass'); + }); + + it('should recognise sass resource in vue external style', () => { + expect(operator.getPreprocessorType({ resource: '/path/to/resource.scss?vue&type=style&index=0&id=0e4a89e8&scoped=true&lang=css&'})).toEqual('sass'); + expect(operator.getPreprocessorType({ resource: '/path/to/resource.sass?vue&type=style&index=0&id=0e4a89e8&scoped=true&lang=css&'})).toEqual('sass'); + }); + it('should recognise less resource', () => { expect(operator.getPreprocessorType({ resource: '/path/to/resource.less'})).toEqual('less'); }); + + it('should recognise sass resource in less inline style', () => { + expect(operator.getPreprocessorType({ resource: '/path/to/resource.vue?vue&type=style&index=0&id=2964abc9&scoped=true&lang=less&'})).toEqual('less'); + }); + + it('should recognise sass resource in less external style', () => { + expect(operator.getPreprocessorType({ resource: '/path/to/resource.less?vue&type=style&index=0&id=0e4a89e8&scoped=true&lang=css&'})).toEqual('less'); + }); + it('throw error if proprocessor type is unknown', () => { const caller = () => { operator.getPreprocessorType({ resource: 'unknown.extension'}); diff --git a/index.js b/index.js index 60541a3..0721e62 100644 --- a/index.js +++ b/index.js @@ -109,11 +109,11 @@ const operator = { const preProcs = [ { type: 'sass', - reg: /\.scss$|\.sass$/ + reg: /\.scss(\?vue.?|$)|\.sass(\?vue.?|$)|\.vue\?.*?lang=scss|\.vue\?.*?lang=sass/ }, { type: 'less', - reg: /\.less$/ + reg: /\.less(\?vue.?|$)|\.vue\?.*?lang=less/ } ];