From b3c5e0e2883bd59be175621e29201b3b0b787a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Sol=C3=A1?= Date: Mon, 1 Aug 2016 22:38:21 +0200 Subject: [PATCH 01/17] Add idPrefix option --- README.md | 7 ++++++ index.js | 6 +++++ lib/transformer.js | 40 ++++++++++++++++++++++++++++++--- tests/fixtures/with-ids.svg | 10 +++++++++ tests/svg-inline-loader.test.js | 13 +++++++++++ 5 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 tests/fixtures/with-ids.svg diff --git a/README.md b/README.md index cf45c35..19b6eeb 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,13 @@ Adds a prefix to class names to avoid collision across svg files. default: `classPrefix: false` +#### `idPrefix: boolean || string` + +Adds a prefix to ids to avoid collision across svg files. + +default: `idPrefix: false` + + ##### Example Usage ```js // Using default hashed prefix (__[hash:base64:7]__) diff --git a/index.js b/index.js index 45b8242..419ff36 100644 --- a/index.js +++ b/index.js @@ -25,6 +25,12 @@ function getExtractedSVG(svgStr, query) { const name = query.classPrefix === true ? '__[hash:base64:7]__' : query.classPrefix; query.classPrefix = loaderUtils.interpolateName({}, name, {content: svgStr}); } + + if (!!query && !!query.idPrefix) { + const id_name = query.idPrefix === true ? '__[hash:base64:7]__' : query.idPrefix; + query.idPrefix = loaderUtils.interpolateName({}, id_name, {content: svgStr}); + } + // Clean-up XML crusts like comments and doctype, etc. var tokens; var cleanedUp = regexSequences.reduce(function (prev, regexSequence) { diff --git a/lib/transformer.js b/lib/transformer.js index 71bb26a..783c0e9 100644 --- a/lib/transformer.js +++ b/lib/transformer.js @@ -18,7 +18,7 @@ function createRemoveTagAttrs(removingTagAttrs) { tag.attributes = tag.attributes.filter(hasNoAttributes); } return tag; - } + }; } function isRemovingTag(removingTags, tag) { @@ -43,7 +43,7 @@ function createRemoveTags(removingTags) { // Reached the end tag of a removingTag removingTag = null; } - } + }; } function getAttributeIndex (tag, attr) { @@ -87,7 +87,40 @@ function createClassPrefix(classPrefix) { } } return tag; - } + }; +} + +function createIdPrefix(idPrefix) { + var url_pattern = /^url\(#.+\)$/i; + return function prefixIds(tag) { + var idIdx = getAttributeIndex(tag, 'id'); + if (idIdx !== -1) { + // prefix id definitions + tag.attributes[idIdx][1] = idPrefix + tag.attributes[idIdx][1]; + } + + if (tag.tagName == 'use') { + // replace references via + var hrefIdx = getAttributeIndex(tag, 'xlink:href'); + if (hrefIdx !== -1) { + tag.attributes[hrefIdx][1] = '#' + idPrefix + tag.attributes[hrefIdx][1].substring(1); + + } + } else if (tag.attributes && tag.attributes.length > 0) { + // replace instances of url(#foo) in attributes + tag.attributes.forEach(function (attr) { + if (attr[1].match(url_pattern)) { + attr[1] = attr[1].replace(url_pattern, function (match) { + var id = match.substring(5, match.length -1); + return "url(#" + idPrefix + id + ")"; + }); + } + + }); + } + + return tag; + }; } function runTransform(tokens, configOverride) { @@ -95,6 +128,7 @@ function runTransform(tokens, configOverride) { var config = conditions.isFilledObject(configOverride) ? assign({}, defaultConfig, configOverride) : defaultConfig; if (config.classPrefix !== false) transformations.push(createClassPrefix(config.classPrefix)); + if (config.idPrefix !== false) transformations.push(createIdPrefix(config.idPrefix)); if (config.removeSVGTagAttrs === true) transformations.push(removeSVGTagAttrs); if (config.removeTags === true) transformations.push(createRemoveTags(config.removingTags)); if (config.removingTagAttrs.length > 0) transformations.push(createRemoveTagAttrs(config.removingTagAttrs)); diff --git a/tests/fixtures/with-ids.svg b/tests/fixtures/with-ids.svg new file mode 100644 index 0000000..822b61c --- /dev/null +++ b/tests/fixtures/with-ids.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/svg-inline-loader.test.js b/tests/svg-inline-loader.test.js index 36a9e1e..977d17f 100644 --- a/tests/svg-inline-loader.test.js +++ b/tests/svg-inline-loader.test.js @@ -47,6 +47,18 @@ describe('getExtractedSVG()', function(){ assert.isTrue( processedStyleInsertedSVG.match(/class="test\.prefix-/g).length === 1 ); }); + it('should apply prefixes to ids', function () { + var svgWithStyle = require('raw!./fixtures/with-ids.svg'); + var processedStyleInsertedSVG = SVGInlineLoader.getExtractedSVG(svgWithStyle, { idPrefix: 'test.prefix-' }); + + + assert.isTrue( processedStyleInsertedSVG.match(/test\.prefix-foo/g).length === 3 ); + // // replaces xlink:href= + assert.isTrue( processedStyleInsertedSVG.match(/xlink:href=/g).length === 1 ); + // // replaces url(#foo) + assert.isTrue( processedStyleInsertedSVG.match(/url\(#test\.prefix-foo\)/g).length === 1 ); + }); + it('should be able to specify tags to be removed by `removingTags` option', function () { var svgRemovingTags = require('raw!./fixtures/removing-tags.svg'); var tobeRemoved = require('./fixtures/removing-tags-to-be-removed.json'); @@ -105,4 +117,5 @@ describe('getExtractedSVG()', function(){ } }); }); + }); From f0396840b6c14b16f95ba2e389aa1380f534b851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Sol=C3=A1?= Date: Fri, 5 Aug 2016 13:41:06 +0200 Subject: [PATCH 02/17] Replace url() references in use tag attributes --- lib/transformer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/transformer.js b/lib/transformer.js index 783c0e9..989df92 100644 --- a/lib/transformer.js +++ b/lib/transformer.js @@ -106,7 +106,8 @@ function createIdPrefix(idPrefix) { tag.attributes[hrefIdx][1] = '#' + idPrefix + tag.attributes[hrefIdx][1].substring(1); } - } else if (tag.attributes && tag.attributes.length > 0) { + } + if (tag.attributes && tag.attributes.length > 0) { // replace instances of url(#foo) in attributes tag.attributes.forEach(function (attr) { if (attr[1].match(url_pattern)) { From 12aef9934adc8e0f472ca62e49d173e58bc17164 Mon Sep 17 00:00:00 2001 From: Jay Jaeho Lee Date: Fri, 16 Sep 2016 18:56:23 +0700 Subject: [PATCH 03/17] chore(release): 0.7.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 35e23f0..050f6f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svg-inline-loader", - "version": "0.6.1", + "version": "0.7.0", "description": "Cleans up and inlines your SVG files into Webpack module.", "main": "index.js", "scripts": { From ba7738d42c9f446b4ef000792a9b2b582b2ba061 Mon Sep 17 00:00:00 2001 From: Richard Date: Sun, 25 Sep 2016 17:08:50 +0200 Subject: [PATCH 04/17] fix: add missing idPrefix as default value to config, close #36 --- config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/config.js b/config.js index 9c65dcf..993e670 100644 --- a/config.js +++ b/config.js @@ -9,4 +9,5 @@ module.exports = { ], removingTagAttrs: [], classPrefix: false, + idPrefix: false, }; From a8d21acae06330de15895b81fdbc1fa5a7b6bbe6 Mon Sep 17 00:00:00 2001 From: Jay Jaeho Lee Date: Wed, 28 Sep 2016 18:43:30 +0900 Subject: [PATCH 05/17] chore(release): 0.7.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 050f6f5..48444f8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svg-inline-loader", - "version": "0.7.0", + "version": "0.7.1", "description": "Cleans up and inlines your SVG files into Webpack module.", "main": "index.js", "scripts": { From 2024e06f68b51c11602400ea74ce2191c1513cf7 Mon Sep 17 00:00:00 2001 From: alok pepakayala Date: Tue, 18 Oct 2016 18:19:13 +0530 Subject: [PATCH 06/17] fix: multiple classes in class string fix - Multiple classses in class attribute not prefixed when using classPrefix --- lib/transformer.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/transformer.js b/lib/transformer.js index 989df92..99bbae8 100644 --- a/lib/transformer.js +++ b/lib/transformer.js @@ -83,7 +83,17 @@ function createClassPrefix(classPrefix) { else { var classIdx = getAttributeIndex(tag,'class'); if(classIdx >= 0) { - tag.attributes[classIdx][1] = classPrefix + tag.attributes[classIdx][1]; + //Prefix classes when multiple classes are present + var classes = tag.attributes[classIdx][1]; + var prefixedClassString = ""; + + classes = classes.replace(/[ ]+/,' '); + classes = classes.split(' '); + classes.forEach(function(classI){ + prefixedClassString += classPrefix + classI + ' '; + }); + + tag.attributes[classIdx][1] = prefixedClassString; } } return tag; From 2d28c424c01f1826557bf724b314f813961d6181 Mon Sep 17 00:00:00 2001 From: alok pepakayala Date: Sat, 22 Oct 2016 03:36:26 +0530 Subject: [PATCH 07/17] fix: corrupted css properties in style tag - For CSS properties that contain '.' in the value. --- lib/transformer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/transformer.js b/lib/transformer.js index 99bbae8..2326c95 100644 --- a/lib/transformer.js +++ b/lib/transformer.js @@ -58,7 +58,8 @@ function getAttributeIndex (tag, attr) { } function createClassPrefix(classPrefix) { - var re = /\.[\w\-]+/g; + //http://stackoverflow.com/questions/12391760/regex-match-css-class-name-from-single-string-containing-multiple-classes + var re = /\.(-?[_a-zA-Z]+[_a-zA-Z0-9-]*)(?![^\{]*\})/g; var inStyleTag = false; return function prefixClasses(tag) { From ada00d772d03a7d49ec53ebbf4ce91b02d326d14 Mon Sep 17 00:00:00 2001 From: nick serebrennikov Date: Wed, 28 Sep 2016 22:36:38 +0300 Subject: [PATCH 08/17] feat: warnTags and warnTagAttrs --- README.md | 11 ++++++++++ config.js | 2 ++ index.js | 2 +- karma.conf.js | 12 +++++------ lib/conditions.js | 7 +++++++ lib/transformer.js | 35 ++++++++++++++++++++++++++++++-- package.json | 1 + tests/svg-inline-loader.test.js | 36 ++++++++++++++++++++++++++++++++- 8 files changed, 96 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 19b6eeb..8866c5b 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,12 @@ warning: this won't work unless you specify `removeTags: true` default: `removingTags: ['title', 'desc', 'defs', 'style']` +#### `warnTags: [...string]` + +warns about tags, ex: ['title', 'desc', 'defs', 'style'] + +default: `warnTags: []` + #### `removeSVGTagAttrs: boolean` Removes `width` and `height` attributes from ``. @@ -43,6 +49,11 @@ Removes attributes from inside the ``. default: `removingTagAttrs: []` +#### `warnTagAttrs: [...string]` + +Warns to console about attributes from inside the ``. + +default: `warnTagAttrs: []` #### `classPrefix: boolean || string` Adds a prefix to class names to avoid collision across svg files. diff --git a/config.js b/config.js index 993e670..5dde54f 100644 --- a/config.js +++ b/config.js @@ -10,4 +10,6 @@ module.exports = { removingTagAttrs: [], classPrefix: false, idPrefix: false, + warnTags: [], + warnTagAttrs: [] }; diff --git a/index.js b/index.js index 419ff36..73cc790 100644 --- a/index.js +++ b/index.js @@ -16,7 +16,7 @@ var regexSequences = [ // SVG XML -> HTML5 [/\<([A-Za-z]+)([^\>]*)\/\>/g, "<$1$2>"], // convert self-closing XML SVG nodes to explicitly closed HTML5 SVG nodes [/\s+/g, " "], // replace whitespace sequences with a single space - [/\> \<"], // remove whitespace between tags + [/\> \<"] // remove whitespace between tags ]; function getExtractedSVG(svgStr, query) { diff --git a/karma.conf.js b/karma.conf.js index 352f746..e830121 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -6,8 +6,8 @@ var webpackConf = { loaders: [ { test: /\.json$/, - loaders: ['json'], - }, + loaders: ['json'] + } ] }, entry: [ @@ -15,7 +15,7 @@ var webpackConf = { ], resolve: { extensions: ["", ".js", ".jsx"], - }, + } }; module.exports = function(config) { @@ -23,11 +23,11 @@ module.exports = function(config) { basePath: '.', frameworks: ['mocha'], files: [ - './tests/**/*.js', + './tests/**/*.js' ], exclude: [], preprocessors: { - './tests/**/*.js': ['webpack'], + './tests/**/*.js': ['webpack'] }, reporters: ['spec'], port: 9876, @@ -39,7 +39,7 @@ module.exports = function(config) { 'karma-spec-reporter', 'karma-mocha', 'karma-chrome-launcher', - 'karma-webpack', + 'karma-webpack' ], webpack: webpackConf, autoWatch: true, diff --git a/lib/conditions.js b/lib/conditions.js index 8f049fa..9157319 100644 --- a/lib/conditions.js +++ b/lib/conditions.js @@ -26,11 +26,18 @@ function createHasNoAttributes(attributes) { } } +function createHasAttributes(attributes) { + return function hasAttributes(attributeToken) { + return attributes.indexOf(attributeToken[0]) > -1; + } +} + module.exports = { isSVGToken: isSVGToken, isStyleToken: isStyleToken, isFilledObject: isFilledObject, hasNoWidthHeight: hasNoWidthHeight, createHasNoAttributes: createHasNoAttributes, + createHasAttributes: createHasAttributes, isStartTag: isStartTag }; diff --git a/lib/transformer.js b/lib/transformer.js index 2326c95..cef721d 100644 --- a/lib/transformer.js +++ b/lib/transformer.js @@ -20,11 +20,30 @@ function createRemoveTagAttrs(removingTagAttrs) { return tag; }; } - +function createWarnTagAttrs(warnTagAttrs) { + warnTagAttrs = warnTagAttrs || []; + var hasNoAttributes = conditions.createHasAttributes(warnTagAttrs); + return function warnTagAttrs(tag) { + if (conditions.isStartTag(tag)) { + var attrs=tag.attributes.filter(hasNoAttributes); + if(attrs.length > 0) { + var attrList=[]; + for(var i=0;i -1; } - +function isWarningTag(warningTags, tag) { + return warningTags.indexOf(tag.tagName) > -1; +} // FIXME: Due to limtation of parser, we need to implement our // very own little state machine to express tree structure @@ -46,6 +65,16 @@ function createRemoveTags(removingTags) { }; } +function createWarnTags(warningTags) { + warningTags = warningTags || []; + + return function warnTags(tag) { + if (conditions.isStartTag(tag) && isWarningTag(warningTags, tag)) { + console.warn('svg-inline-loader: forbidden tag ' + tag.tagName); + } + return tag; + }; +} function getAttributeIndex (tag, attr) { if( tag.attributes !== undefined && tag.attributes.length > 0 ) { for(var i = 0; i < tag.attributes.length; i++) { @@ -142,7 +171,9 @@ function runTransform(tokens, configOverride) { if (config.classPrefix !== false) transformations.push(createClassPrefix(config.classPrefix)); if (config.idPrefix !== false) transformations.push(createIdPrefix(config.idPrefix)); if (config.removeSVGTagAttrs === true) transformations.push(removeSVGTagAttrs); + if (config.warnTags.length > 0) transformations.push(createWarnTags(config.warnTags)); if (config.removeTags === true) transformations.push(createRemoveTags(config.removingTags)); + if (config.warnTagAttrs.length > 0) transformations.push(createWarnTagAttrs(config.warnTagAttrs)); if (config.removingTagAttrs.length > 0) transformations.push(createRemoveTagAttrs(config.removingTagAttrs)); transformations.forEach(function (transformation) { diff --git a/package.json b/package.json index 48444f8..4adcf7d 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ }, "devDependencies": { "chai": "^3.0.0", + "chai-spies": "^0.7.1", "json-loader": "^0.5.4", "karma": "^1.0.0", "karma-chrome-launcher": "^1.0.1", diff --git a/tests/svg-inline-loader.test.js b/tests/svg-inline-loader.test.js index 977d17f..676440c 100644 --- a/tests/svg-inline-loader.test.js +++ b/tests/svg-inline-loader.test.js @@ -2,7 +2,12 @@ var simpleHTMLTokenizer = require('simple-html-tokenizer'); var tokenize = simpleHTMLTokenizer.tokenize; var SVGInlineLoader = require('../index'); -var assert = require('chai').assert; +var chai = require('chai'); +var assert = chai.assert; +var expect = chai.expect; +var spies = require('chai-spies'); +chai.use(spies); +var createSpy = chai.spy; var _ = require('lodash'); var svgWithRect = require('raw!./fixtures/xml-rect.svg'); @@ -117,5 +122,34 @@ describe('getExtractedSVG()', function(){ } }); }); + it('should be able to warn about tagsAttrs to be removed listed in `warnTagAttrs` option via console.log', function () { + var svg = require('raw!./fixtures/with-ids.svg'); + var tobeWarned = ['id']; + var oldConsoleWarn = console.warn; + var warnings=[]; + console.warn=createSpy(function (str) { + warnings.push(str); + }); + var processedSVG = SVGInlineLoader.getExtractedSVG(svg, { warnTagAttrs: tobeWarned }); + var reTokenizedSVG = tokenize(processedSVG); + expect(console.warn).to.have.been.called.with('svg-inline-loader: tag path has forbidden attrs: id'); + console.warn = oldConsoleWarn; // reset console back + }); + it('should be able to specify tags to be warned about by `warnTags` option', function () { + var svg = require('raw!./fixtures/removing-tags.svg'); + var tobeWarnedAbout = ['title', 'desc', 'defs', 'style', 'image']; + var oldConsoleWarn = console.warn; + var warnings=[]; + console.warn=createSpy(function (str) { + warnings.push(str); + }); + var processedStyleInsertedSVG = SVGInlineLoader.getExtractedSVG(svg, { warnTags: tobeWarnedAbout }); + var reTokenizedStyleInsertedSVG = tokenize(processedStyleInsertedSVG); + + expect(console.warn).to.have.been.called(); + expect(console.warn).to.have.been.called.min(3); + expect(console.warn).to.have.been.called.with('svg-inline-loader: forbidden tag style'); + console.warn = oldConsoleWarn; // reset console back + }); }); From 71869510da355c8a4b4632b19989a04eda35785a Mon Sep 17 00:00:00 2001 From: Nick Serebrennikov Date: Thu, 29 Sep 2016 09:50:50 +0300 Subject: [PATCH 09/17] docs: Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8866c5b..2f70657 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ default: `removingTags: ['title', 'desc', 'defs', 'style']` #### `warnTags: [...string]` -warns about tags, ex: ['title', 'desc', 'defs', 'style'] +warns about tags, ex: ['desc', 'defs', 'style'] default: `warnTags: []` From 9373e3e8d5386c7e4ca777011a6f4e7621b334b2 Mon Sep 17 00:00:00 2001 From: Andrew Gerard Date: Fri, 18 Nov 2016 16:28:47 -0700 Subject: [PATCH 10/17] fix: don't transform webpack2 query objects --- index.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 73cc790..584d278 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ var simpleHTMLTokenizer = require('simple-html-tokenizer'); var tokenize = simpleHTMLTokenizer.tokenize; var generate = simpleHTMLTokenizer.generate; var loaderUtils = require('loader-utils'); +var assign = require('object-assign'); var conditions = require('./lib/conditions'); var transformer = require('./lib/transformer'); @@ -20,15 +21,20 @@ var regexSequences = [ ]; function getExtractedSVG(svgStr, query) { + var config; // interpolate hashes in classPrefix - if(!!query && !!query.classPrefix) { - const name = query.classPrefix === true ? '__[hash:base64:7]__' : query.classPrefix; - query.classPrefix = loaderUtils.interpolateName({}, name, {content: svgStr}); - } + if(!!query) { + config = assign({}, query); + + if (!!config.classPrefix) { + const name = config.classPrefix === true ? '__[hash:base64:7]__' : config.classPrefix; + config.classPrefix = loaderUtils.interpolateName({}, name, { content: svgStr }); + } - if (!!query && !!query.idPrefix) { - const id_name = query.idPrefix === true ? '__[hash:base64:7]__' : query.idPrefix; - query.idPrefix = loaderUtils.interpolateName({}, id_name, {content: svgStr}); + if (!!config.idPrefix) { + const id_name = config.idPrefix === true ? '__[hash:base64:7]__' : config.idPrefix; + config.idPrefix = loaderUtils.interpolateName({}, id_name, { content: svgStr }); + } } // Clean-up XML crusts like comments and doctype, etc. @@ -47,7 +53,7 @@ function getExtractedSVG(svgStr, query) { } // If the token is start-tag, then remove width and height attributes. - return generate(transformer.runTransform(tokens, query)); + return generate(transformer.runTransform(tokens, config)); } function SVGInlineLoader(content) { From e00f6bc71f85b3d89965814f55a6c8f55792f249 Mon Sep 17 00:00:00 2001 From: Stuart Knightley Date: Fri, 27 Jan 2017 13:40:21 -0800 Subject: [PATCH 11/17] Add license file --- LICENSE | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ba47863 --- /dev/null +++ b/LICENSE @@ -0,0 +1,18 @@ +Copyright 2015-2017 Jaeho Lee + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From b652e1716d59e2332234de77484f94938601526c Mon Sep 17 00:00:00 2001 From: Jaeho Lee Date: Tue, 7 Mar 2017 16:28:06 +0900 Subject: [PATCH 12/17] Update license to js foundation license (fixes #49) --- LICENSE | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/LICENSE b/LICENSE index ba47863..8c11fc7 100644 --- a/LICENSE +++ b/LICENSE @@ -1,18 +1,20 @@ -Copyright 2015-2017 Jaeho Lee +Copyright JS Foundation and other contributors -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 32349e0ff8ee4d42cc93d2e7b23be5ea07b6462f Mon Sep 17 00:00:00 2001 From: Joshua Wiens Date: Tue, 7 Mar 2017 01:58:35 -0600 Subject: [PATCH 13/17] docs(readme): contrib standard readme (#50) --- README.md | 90 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 76 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 2f70657..a9d8e2d 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,27 @@ -**NOTICE [2016-06-26]: I'm not using or developing this lib anymore. Therefore I'm closing issues (which I cannot handle anymore), but you can send PR to improve or fix problems you facing with this lib.** - -# SVG Inline Loader for Webpack - -This Webpack loader inlines SVG as module. If you use Adobe suite or Sketch to export SVGs, you will get auto-generated, unneeded crusts. This loader removes it for you, too. +[![npm][npm]][npm-url] +[![deps][deps]][deps-url] +[![test][test]][test-url] +[![coverage][cover]][cover-url] +[![quality][quality]][quality-url] +[![chat][chat]][chat-url] + +
+ + + + +

SVG Inline Loader for Webpack

+

This Webpack loader inlines SVG as module. If you use Adobe suite or Sketch to export SVGs, you will get auto-generated, unneeded crusts. This loader removes it for you, too.

+

+ +

Install

+ +```bash +npm install svg-inline-loader --save-dev +``` -## Config +

Configuration

Simply add configuration object to `module.loaders` like this. @@ -15,9 +32,9 @@ Simply add configuration object to `module.loaders` like this. } ``` -warning: You should configure this loader only once via `module.loaders` or `require('!...')`. See [#15](https://github.com/sairion/svg-inline-loader/issues/15) for detail. +warning: You should configure this loader only once via `module.loaders` or `require('!...')`. See [#15](https://github.com/webpack-contrib/svg-inline-loader/issues/15) for detail. -### query options +

Query Options

#### `removeTags: boolean` @@ -66,8 +83,8 @@ Adds a prefix to ids to avoid collision across svg files. default: `idPrefix: false` +

Example Usage

-##### Example Usage ```js // Using default hashed prefix (__[hash:base64:7]__) var logoTwo = require('svg-inline?classPrefix!./logo_two.svg'); @@ -88,8 +105,53 @@ Preferred usage is via a `module.loaders`: } ``` -## Notes - -- `` React Component is **DEPRECATED**, use `svg-inline-react` package instead. -- Known problems: - - currently inlining SVG in css is unable. See #22 +

Maintainers

+ + + + + + + + + + +
+ +
+ Juho Vepsäläinen +
+ +
+ Joshua Wiens +
+ +
+ Kees Kluskens +
+ +
+ Sean Larkin +
+ +[npm]: https://img.shields.io/npm/v/svg-inline-loader.svg +[npm-url]: https://npmjs.com/package/svg-inline-loader + +[deps]: https://david-dm.org/webpack-contrib/svg-inline-loader.svg +[deps-url]: https://david-dm.org/webpack-contrib/svg-inline-loader + +[chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg +[chat-url]: https://gitter.im/webpack/webpack + +[test]: https://travis-ci.org/webpack-contrib/svg-inline-loader.svg?branch=master +[test-url]: https://travis-ci.org/webpack-contrib/svg-inline-loader + +[cover]: https://codecov.io/gh/webpack-contrib/svg-inline-loader/branch/master/graph/badge.svg +[cover-url]: https://codecov.io/gh/webpack-contrib/svg-inline-loader + +[quality]: https://www.bithound.io/github/webpack-contrib/svg-inline-loader/badges/score.svg +[quality-url]: https://www.bithound.io/github/webpack-contrib/svg-inline-loader From 4126d573554c3de58a491402a4dc8b0645fe98bf Mon Sep 17 00:00:00 2001 From: Joshua Wiens Date: Tue, 7 Mar 2017 01:59:15 -0600 Subject: [PATCH 14/17] docs(readme): remove bithound badge --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index a9d8e2d..b041b11 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![deps][deps]][deps-url] [![test][test]][test-url] [![coverage][cover]][cover-url] -[![quality][quality]][quality-url] [![chat][chat]][chat-url]
@@ -152,6 +151,3 @@ Preferred usage is via a `module.loaders`: [cover]: https://codecov.io/gh/webpack-contrib/svg-inline-loader/branch/master/graph/badge.svg [cover-url]: https://codecov.io/gh/webpack-contrib/svg-inline-loader - -[quality]: https://www.bithound.io/github/webpack-contrib/svg-inline-loader/badges/score.svg -[quality-url]: https://www.bithound.io/github/webpack-contrib/svg-inline-loader From 2b7dcc99f7bb82d8a1f42373163dbfcf06cd0419 Mon Sep 17 00:00:00 2001 From: Jaeho Lee Date: Thu, 30 Mar 2017 03:31:24 +0900 Subject: [PATCH 15/17] docs: Update usage documentation (#54) closes #53 --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b041b11..5285eb5 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Simply add configuration object to `module.loaders` like this. ```javascript { test: /\.svg$/, - loader: 'svg-inline' + loader: 'svg-inline-loader' } ``` @@ -86,13 +86,13 @@ default: `idPrefix: false` ```js // Using default hashed prefix (__[hash:base64:7]__) -var logoTwo = require('svg-inline?classPrefix!./logo_two.svg'); +var logoTwo = require('svg-inline-loader?classPrefix!./logo_two.svg'); // Using custom string -var logoOne = require('svg-inline?classPrefix=my-prefix-!./logo_one.svg'); +var logoOne = require('svg-inline-loader?classPrefix=my-prefix-!./logo_one.svg'); // Using custom string and hash -var logoThree = require('svg-inline?classPrefix=__prefix-[sha512:hash:hex:5]__!./logo_three.svg'); +var logoThree = require('svg-inline-loader?classPrefix=__prefix-[sha512:hash:hex:5]__!./logo_three.svg'); ``` See [loader-utils](https://github.com/webpack/loader-utils#interpolatename) for hash options. @@ -100,7 +100,7 @@ Preferred usage is via a `module.loaders`: ```js { test: /\.svg$/, - loader: 'svg-inline?classPrefix' + loader: 'svg-inline-loader?classPrefix' } ``` From ff568a912d30de1e1b1834f6854592520a0ed52e Mon Sep 17 00:00:00 2001 From: Joshua Wiens Date: Sat, 15 Jul 2017 22:12:33 -0500 Subject: [PATCH 16/17] chore: Adds release tooling --- package.json | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 4adcf7d..ec123ce 100644 --- a/package.json +++ b/package.json @@ -2,26 +2,13 @@ "name": "svg-inline-loader", "version": "0.7.1", "description": "Cleans up and inlines your SVG files into Webpack module.", - "main": "index.js", - "scripts": { - "test": "karma start" - }, "author": "Jaeho Lee ", "license": "MIT", - "repository": { - "type": "git", - "url": "git@github.com:sairion/svg-inline-loader.git" - }, - "keywords": [ - "svg", - "webpack", - "react", - "loader" - ], - "bugs": { - "url": "https://github.com/sairion/svg-inline-loader/issues" + "main": "index.js", + "scripts": { + "test": "karma start", + "release": "standard-version" }, - "homepage": "https://github.com/sairion/svg-inline-loader", "dependencies": { "loader-utils": "^0.2.11", "object-assign": "^4.0.1", @@ -40,6 +27,21 @@ "mocha": "^2.5.3", "node-libs-browser": "^1.0.0", "raw-loader": "^0.5.1", + "standard-version": "^4.2.0", "webpack": "^1.13.1" - } -} + }, + "repository": { + "type": "git", + "url": "git@github.com:sairion/svg-inline-loader.git" + }, + "bugs": { + "url": "https://github.com/sairion/svg-inline-loader/issues" + }, + "homepage": "https://github.com/sairion/svg-inline-loader", + "keywords": [ + "svg", + "webpack", + "react", + "loader" + ] +} \ No newline at end of file From 99af8063c2c1a47a7a554a094c5a43c9b22cdccd Mon Sep 17 00:00:00 2001 From: Joshua Wiens Date: Sat, 15 Jul 2017 22:49:33 -0500 Subject: [PATCH 17/17] chore(release): 0.8.0 --- CHANGELOG.md | 22 ++++++++++++++++++++++ package.json | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 676329f..558aa03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,25 @@ +# Change Log + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + + +# [0.8.0](https://github.com/sairion/svg-inline-loader/compare/0.6.1...v0.8.0) (2017-07-16) + + +### Bug Fixes + +* add missing idPrefix as default value to config, close [#36](https://github.com/sairion/svg-inline-loader/issues/36) ([ba7738d](https://github.com/sairion/svg-inline-loader/commit/ba7738d)) +* corrupted css properties in style tag ([2d28c42](https://github.com/sairion/svg-inline-loader/commit/2d28c42)) +* don't transform webpack2 query objects ([9373e3e](https://github.com/sairion/svg-inline-loader/commit/9373e3e)) +* multiple classes in class string fix ([2024e06](https://github.com/sairion/svg-inline-loader/commit/2024e06)) + + +### Features + +* warnTags and warnTagAttrs ([ada00d7](https://github.com/sairion/svg-inline-loader/commit/ada00d7)) + + + # Changelog ## 0.6.1 diff --git a/package.json b/package.json index ec123ce..d6771dc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svg-inline-loader", - "version": "0.7.1", + "version": "0.8.0", "description": "Cleans up and inlines your SVG files into Webpack module.", "author": "Jaeho Lee ", "license": "MIT", @@ -44,4 +44,4 @@ "react", "loader" ] -} \ No newline at end of file +}