diff --git a/src/lib/paths.js b/src/lib/paths.js index eef8ef8..d7f76c4 100644 --- a/src/lib/paths.js +++ b/src/lib/paths.js @@ -35,7 +35,10 @@ const isUrlWithoutPathname = (assetUrl) => { * @returns {Boolean} */ const isUrlShouldBeIgnored = (assetUrl, options) => { - return isUrlWithoutPathname(assetUrl) || (assetUrl[0] === '/' && !options.basePath); + const isAbsolutePath = assetUrl[0] === '/'; + const isStartsWithTilde = assetUrl[0] === '~'; + + return isUrlWithoutPathname(assetUrl) || ((isAbsolutePath || isStartsWithTilde) && !options.basePath); }; /** diff --git a/src/type/copy.js b/src/type/copy.js index 48d02d9..2f1da06 100644 --- a/src/type/copy.js +++ b/src/type/copy.js @@ -13,7 +13,7 @@ const getAssetsPath = paths.getAssetsPath; const normalize = paths.normalize; const getHashName = (file, options) => - (options && options.append ? (path.basename(file.path, path.extname(file.path)) + '_') : '') + (options && options.append ? (`${path.basename(file.path, path.extname(file.path))}_`) : '') + calcHash(file.contents, options) + path.extname(file.path); diff --git a/test/fixtures/skip-urls-with-tilde.css b/test/fixtures/skip-urls-with-tilde.css new file mode 100644 index 0000000..0baa467 --- /dev/null +++ b/test/fixtures/skip-urls-with-tilde.css @@ -0,0 +1,3 @@ +body { + background: url("~one"), url("~./two"), url("~@three"), url("~@four/qwe"); +} diff --git a/test/fixtures/skip-urls-with-tilde.expected.css b/test/fixtures/skip-urls-with-tilde.expected.css new file mode 100644 index 0000000..0baa467 --- /dev/null +++ b/test/fixtures/skip-urls-with-tilde.expected.css @@ -0,0 +1,3 @@ +body { + background: url("~one"), url("~./two"), url("~@three"), url("~@four/qwe"); +} diff --git a/test/type/copy.js b/test/type/copy.js index 353cbff..56caef0 100644 --- a/test/type/copy.js +++ b/test/type/copy.js @@ -1,3 +1,8 @@ +compareFixtures( + 'skip-urls-with-tilde', + 'should skip URLs with tilde' +); + describe('copy without assetsPath', () => { const opts = { url: 'copy' diff --git a/test/type/inline.js b/test/type/inline.js index 1b6019c..3b1dba0 100644 --- a/test/type/inline.js +++ b/test/type/inline.js @@ -24,6 +24,11 @@ describe('inline', () => { postcssOpts ); + compareFixtures( + 'skip-urls-with-tilde', + 'should skip URLs with tilde' + ); + it('should inline url from dirname(from)', () => { const css = processedCss('fixtures/inline-from', opts, postcssOpts); diff --git a/test/type/rebase.js b/test/type/rebase.js index b8d0350..ef80325 100644 --- a/test/type/rebase.js +++ b/test/type/rebase.js @@ -86,4 +86,8 @@ describe('rebase', () => { opts, { from: 'test/fixtures/here', to: 'there' } ); + compareFixtures( + 'skip-urls-with-tilde', + 'should skip URLs with tilde' + ); });