Skip to content

Commit

Permalink
Merge pull request #11 from constgen/vue-external-style
Browse files Browse the repository at this point in the history
Vue external style support
  • Loading branch information
tompascall authored Mar 1, 2021
2 parents e19b012 + be25651 commit 31b0790
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions __tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'});
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ const operator = {
const preProcs = [
{
type: 'sass',
reg: /\.scss$|\.sass$|\.vue\?.*?lang=scss|\.vue\?.*?lang=sass/
reg: /\.scss(\?vue.?|$)|\.sass(\?vue.?|$)|\.vue\?.*?lang=scss|\.vue\?.*?lang=sass/
},
{
type: 'less',
reg: /\.less$|\.vue\?.*?lang=less/
reg: /\.less(\?vue.?|$)|\.vue\?.*?lang=less/
}
];

Expand Down

0 comments on commit 31b0790

Please sign in to comment.