Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,13 @@ module.exports = {
options: {
url: (url, resourcePath) => {
// resourcePath - path to css file

// Don't handle `img.png` urls
if (url.includes('img.png')) {
return false;
}

// `url()` with `img.png` stay untouched
return url.includes('img.png');
return true;
},
},
},
Expand Down Expand Up @@ -262,8 +266,12 @@ module.exports = {
// parsedImport.media - media query of `@import`
// resourcePath - path to css file

// `@import` with `style.css` stay untouched
return parsedImport.url.includes('style.css');
// Don't handle `style.css` import
if (parsedImport.url.includes('style.css')) {
return false;
}

return true;
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ function getLocalIdent(loaderContext, localIdentName, localName, options) {
}

function getFilter(filter, resourcePath, defaultFilter = null) {
return (content) => {
if (defaultFilter && !defaultFilter(content)) {
return (item) => {
if (defaultFilter && !defaultFilter(item)) {
return false;
}

if (typeof filter === 'function') {
return !filter(content, resourcePath);
return filter(item, resourcePath);
}

return true;
Expand Down
7 changes: 6 additions & 1 deletion test/import-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ describe('import option', () => {
import: (parsedImport, resourcePath) => {
expect(typeof resourcePath === 'string').toBe(true);

return parsedImport.url.includes('test.css');
// Don't handle `test.css`
if (parsedImport.url.includes('test.css')) {
return false;
}

return true;
},
},
},
Expand Down
7 changes: 6 additions & 1 deletion test/url-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ describe('url option', () => {
url: (url, resourcePath) => {
expect(typeof resourcePath === 'string').toBe(true);

return url.includes('img.png');
// Don't handle `img.png`
if (url.includes('img.png')) {
return false;
}

return true;
},
},
},
Expand Down