diff --git a/README.md b/README.md index 084f1c62..54d820f9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# html loader for webpack +# vue-html-loader + +> This is a fork of the webpack html-loader with some parser improvements and some Vue.js specific fixes. Used by vue-loader as a peer dependency. Usage is exactly the same with the original html-loader. Exports HTML as string. HTML is minimized when the compiler demands. diff --git a/index.js b/index.js index 928ee2ab..238311d0 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,6 @@ function randomIdent() { return "xxxHTMLLINKxxx" + Math.random() + Math.random() + "xxx"; }; - module.exports = function(content) { this.cacheable && this.cacheable(); var query = loaderUtils.parseQuery(this.query); @@ -65,7 +64,9 @@ module.exports = function(content) { removeRedundantAttributes: query.removeRedundantAttributes !== false, useShortDoctype: query.useShortDoctype !== false, removeEmptyAttributes: query.removeEmptyAttributes !== false, - removeOptionalTags: query.removeOptionalTags !== false + removeOptionalTags: query.removeOptionalTags !== false, + // required for Vue 1.0 shorthand syntax + customAttrSurround: [[/@/, new RegExp('')], [/:/, new RegExp('')]] }); } return "module.exports = " + JSON.stringify(content).replace(/xxxHTMLLINKxxx[0-9\.]+xxx/g, function(match) { diff --git a/lib/attributesParser.js b/lib/attributesParser.js index 507b7207..22589c63 100644 --- a/lib/attributesParser.js +++ b/lib/attributesParser.js @@ -27,9 +27,9 @@ var parser = new Parser({ inside: { "\\s+": true, // eat up whitespace ">": "outside", // end of attributes - "(([a-zA-Z\\-]+)\\s*=\\s*\")([^\"]*)\"": processMatch, - "(([a-zA-Z\\-]+)\\s*=\\s*\')([^\']*)\'": processMatch, - "(([a-zA-Z\\-]+)\\s*=\\s*)([^\\s>]+)": processMatch + "(([0-9a-zA-Z\\-:\.]+)\\s*=\\s*\")([^\"]*)\"": processMatch, + "(([0-9a-zA-Z\\-:\.]+)\\s*=\\s*\')([^\']*)\'": processMatch, + "(([0-9a-zA-Z\\-:\.]+)\\s*=\\s*)([^\\s>]+)": processMatch } }); @@ -40,4 +40,4 @@ module.exports = function parse(html, isRelevantTagAttr) { results: [], isRelevantTagAttr: isRelevantTagAttr }).results; -}; \ No newline at end of file +}; diff --git a/package.json b/package.json index 7a0d4c65..23ff07e0 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { - "name": "html-loader", - "version": "0.3.0", + "name": "vue-html-loader", + "version": "1.0.0", "author": "Tobias Koppers @sokra", "description": "html loader module for webpack", "dependencies": { - "html-minifier": "^0.7.2", - "source-map": "0.1.x", - "fastparse": "^1.0.0", - "loader-utils": "~0.2.2" + "html-minifier": "^0.8.0", + "source-map": "^0.5.1", + "fastparse": "^1.1.1", + "loader-utils": "^0.2.11" }, "devDependencies": { "mocha": "1.17.x", diff --git a/test/loaderTest.js b/test/loaderTest.js index 104d11d6..692fc6af 100644 --- a/test/loaderTest.js +++ b/test/loaderTest.js @@ -38,9 +38,16 @@ describe("loader", function() { loader.call({ minimize: true }, '
{title}
\n\t{title}
{title}