From 53ff82b9a311c0a30376b8a9ecb55ed2292c4824 Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 1 Oct 2015 14:46:58 -0400 Subject: [PATCH 01/15] parser: support full valid attr charset --- lib/attributesParser.js | 6 +++--- test/parserTest.js | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/attributesParser.js b/lib/attributesParser.js index ff49026f..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 - "(([0-9a-zA-Z\\-:]+)\\s*=\\s*\")([^\"]*)\"": processMatch, - "(([0-9a-zA-Z\\-:]+)\\s*=\\s*\')([^\']*)\'": processMatch, - "(([0-9a-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 } }); diff --git a/test/parserTest.js b/test/parserTest.js index aa05c64a..a49c4bd8 100644 --- a/test/parserTest.js +++ b/test/parserTest.js @@ -9,6 +9,7 @@ function test(name, html, result) { if(tag === "link" && attr === "href") return true; if(tag === "div" && attr === "data-videomp4") return true; if(tag === "use" && attr === "xlink:href") return true; + if(tag === "div" && /data-/.test(attr)) return true; return false; }).map(function(match) { return match.value }).should.be.eql(result); }); @@ -32,6 +33,7 @@ describe("parser", function() { test("doctype", '', ["image.png"]); test("alphanumeric", '
', ["video.mp4"]); test("use", '', ["vector.svg"]); + test("vue shorthands", '', []); }); describe("locations", function() { From 6c84fae7aa0309d7de4250587993291ae432c290 Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 1 Oct 2015 14:51:52 -0400 Subject: [PATCH 02/15] add support for minifying vue 1.0 templates --- index.js | 3 +++ test/loaderTest.js | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/index.js b/index.js index d751899d..08e964b6 100644 --- a/index.js +++ b/index.js @@ -87,6 +87,9 @@ module.exports = function(content) { } }); + // required for Vue 1.0 shorthand syntax + minimizeOptions.customAttrSurround = [[/@/, new RegExp('')], [/:/, new RegExp('')]] + content = htmlMinifier.minify(content, minimizeOptions); } diff --git a/test/loaderTest.js b/test/loaderTest.js index cb024368..9b12ce66 100644 --- a/test/loaderTest.js +++ b/test/loaderTest.js @@ -90,6 +90,13 @@ describe("loader", function() { 'module.exports = "

{{ count <= 1 ? \\"foo\\" : \\"bar\\" }}

";' ); }); + it('should minimize vue template', function () { + loader.call({ + minimize: true + }, '
\n hihihi {{what}} \n
').should.be.eql( + 'module.exports = "
hihihi {{what}}
";' + ); + }) it("should not translate root-relative urls (without root query)", function() { loader.call({}, 'Text ').should.be.eql( 'module.exports = "Text ";' From cce5ef6e32e7fedf153ce6e832d770bd145e42cd Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 16 Feb 2016 22:51:19 -0500 Subject: [PATCH 03/15] change name, config field, readme --- README.md | 63 ++++++++++++++++++---------------------------------- index.js | 5 +---- package.json | 10 ++++----- 3 files changed, 28 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 262372ca..09e819e0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,25 @@ -# html loader for webpack +# vue-html-loader + +> This is a fork of [html-loader](https://github.com/webpack/html-loader) with some modifications for handling Vue templates. + +## Config + +You can config the loader's behavior by adding an `html` field under `vue` in your webpack config: + +``` js +// webpack.config.js +module.exports = { + // ... + vue: { + html: { + // all loader queries can be specified here + // also, you can specify options for htmlMinifier here. + } + } +} +``` + +## Original README below Exports HTML as string. HTML is minimized when the compiler demands. @@ -87,46 +108,6 @@ require("html?interpolate!./file.html");
${require('./partials/gallery.html')}
``` -## Advanced options - -If you need to pass [more advanced options](https://github.com/webpack/html-loader/pull/46), especially those which cannot be stringified, you can also define an `htmlLoader`-property on your `webpack.config.js`: - -``` javascript -module.exports = { - ... - module: { - loaders: [ - { - test: /\.html$/, - loader: "html" - } - ] - } - htmlLoader: { - ignoreCustomFragments: [/\{\{.*?}}/] - } -}; -``` - -If you need to define two different loader configs, you can also change the config's property name via `html?config=otherHtmlLoaderConfig`: - -```javascript -module.exports = { - ... - module: { - loaders: [ - { - test: /\.html$/, - loader: "html?config=otherHtmlLoaderConfig" - } - ] - } - otherHtmlLoaderConfig: { - ... - } -}; -``` - ## License MIT (http://www.opensource.org/licenses/mit-license.php) diff --git a/index.js b/index.js index 08e964b6..cfbb620f 100644 --- a/index.js +++ b/index.js @@ -15,11 +15,8 @@ function randomIdent() { function getLoaderConfig(context) { var query = loaderUtils.parseQuery(context.query); - var configKey = query.config || 'htmlLoader'; - var config = context.options && context.options.hasOwnProperty(configKey) ? context.options[configKey] : {}; - + var config = (context.options && context.options.vue && context.options.vue.html) || {}; delete query.config; - return assign(query, config); } diff --git a/package.json b/package.json index 0389d29e..4735db27 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "html-loader", - "version": "0.4.3", - "author": "Tobias Koppers @sokra", - "description": "html loader module for webpack", + "name": "vue-html-loader", + "version": "1.2.0", + "author": "Evan You", + "description": "vue template loader for webpack", "dependencies": { "es6-templates": "^0.2.2", "fastparse": "^1.0.0", @@ -19,7 +19,7 @@ }, "repository": { "type": "git", - "url": "git@github.com:webpack/html-loader.git" + "url": "git@github.com:vuejs/vue-html-loader.git" }, "licenses": [ { From 019bae4d214747a4c6bf51e099884044eb0baeed Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 1 Apr 2016 16:43:08 -0400 Subject: [PATCH 04/15] do not turn on minifyJS/minifyCSS by default --- index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/index.js b/index.js index cfbb620f..cc44e231 100644 --- a/index.js +++ b/index.js @@ -74,8 +74,6 @@ module.exports = function(content) { "removeAttributeQuotes", "useShortDoctype", "keepClosingSlash", - "minifyJS", - "minifyCSS", "removeScriptTypeAttributes", "removeStyleTypeAttributes", ].forEach(function(name) { From 61fb4ff0dd849da0f8e60699c079d35a94073314 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 1 Apr 2016 16:43:11 -0400 Subject: [PATCH 05/15] 1.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4735db27..4b5e8b3a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-html-loader", - "version": "1.2.0", + "version": "1.2.1", "author": "Evan You", "description": "vue template loader for webpack", "dependencies": { From 6028f2de3b690f15edb370f7b14eed106b0afcba Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 1 Apr 2016 16:47:25 -0400 Subject: [PATCH 06/15] fix test case --- test/loaderTest.js | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/test/loaderTest.js b/test/loaderTest.js index 9b12ce66..b6c17d4c 100644 --- a/test/loaderTest.js +++ b/test/loaderTest.js @@ -69,27 +69,16 @@ describe("loader", function() { loader.call({ minimize: true, options: { - htmlLoader: { - ignoreCustomFragments: [/\{\{.*?}}/] + vue: { + html: { + ignoreCustomFragments: [/\{\{.*?}}/] + } } } }, '

{{ count <= 1 ? "foo" : "bar" }}

').should.be.eql( 'module.exports = "

{{ count <= 1 ? \\"foo\\" : \\"bar\\" }}

";' ); }); - it("should allow the webpack config property name to be configured", function() { - loader.call({ - minimize: true, - options: { - htmlLoaderSuperSpecialConfig: { - ignoreCustomFragments: [/\{\{.*?}}/] - } - }, - query: '?config=htmlLoaderSuperSpecialConfig' - }, '

{{ count <= 1 ? "foo" : "bar" }}

').should.be.eql( - 'module.exports = "

{{ count <= 1 ? \\"foo\\" : \\"bar\\" }}

";' - ); - }); it('should minimize vue template', function () { loader.call({ minimize: true From 9fd7ef6fe6a12fdf3712a7f51fe6840cad811a3d Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 6 Apr 2016 13:19:08 -0400 Subject: [PATCH 07/15] update html-minifier & fix tests --- index.js | 5 +---- package.json | 2 +- test/loaderTest.js | 12 ++++++------ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index cc44e231..3cc45634 100644 --- a/index.js +++ b/index.js @@ -75,16 +75,13 @@ module.exports = function(content) { "useShortDoctype", "keepClosingSlash", "removeScriptTypeAttributes", - "removeStyleTypeAttributes", + "removeStyleTypeAttributes" ].forEach(function(name) { if(typeof minimizeOptions[name] === "undefined") { minimizeOptions[name] = true; } }); - // required for Vue 1.0 shorthand syntax - minimizeOptions.customAttrSurround = [[/@/, new RegExp('')], [/:/, new RegExp('')]] - content = htmlMinifier.minify(content, minimizeOptions); } diff --git a/package.json b/package.json index 4b5e8b3a..b27a51d8 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "dependencies": { "es6-templates": "^0.2.2", "fastparse": "^1.0.0", - "html-minifier": "^1.0.0", + "html-minifier": "^1.4.0", "loader-utils": "~0.2.2", "object-assign": "^4.0.1" }, diff --git a/test/loaderTest.js b/test/loaderTest.js index b6c17d4c..faf5f6fd 100644 --- a/test/loaderTest.js +++ b/test/loaderTest.js @@ -38,7 +38,7 @@ describe("loader", function() { loader.call({ minimize: true }, '

#{number} {customer}

\n

{title}

\n\t ').should.be.eql( - 'module.exports = "

#{number} {customer}

{title}

";' + 'module.exports = "

#{number} {customer}

{title}

";' ); }); // https://github.com/webpack/webpack/issues/752 @@ -46,7 +46,7 @@ describe("loader", function() { loader.call({ minimize: true }, '').should.be.eql( - 'module.exports = "";' + 'module.exports = "";' ); }); it("should preserve comments", function() { @@ -54,7 +54,7 @@ describe("loader", function() { minimize: true, query: "?-removeComments" }, '

#{number} {customer}

{title}

').should.be.eql( - 'module.exports = "

#{number} {customer}

{title}

";' + 'module.exports = "

#{number} {customer}

{title}

";' ); }); it("should treat attributes as case sensitive", function() { @@ -62,7 +62,7 @@ describe("loader", function() { minimize: true, query: "?caseSensitive" }, '

#{number} {customer}

{title}

').should.be.eql( - 'module.exports = "

#{number} {customer}

{title}

";' + 'module.exports = "

#{number} {customer}

{title}

";' ); }); it("should accept complex options via a webpack config property", function() { @@ -82,8 +82,8 @@ describe("loader", function() { it('should minimize vue template', function () { loader.call({ minimize: true - }, '
\n hihihi {{what}} \n
').should.be.eql( - 'module.exports = "
hihihi {{what}}
";' + }, '
\n hihihi {{what}} \n
').should.be.eql( + 'module.exports = "
hihihi {{what}}
";' ); }) it("should not translate root-relative urls (without root query)", function() { From b8083c29f30eb3b205fb792b1bbb68d73e67fb6a Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 6 Apr 2016 13:19:13 -0400 Subject: [PATCH 08/15] 1.2.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b27a51d8..b6eca857 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-html-loader", - "version": "1.2.1", + "version": "1.2.2", "author": "Evan You", "description": "vue template loader for webpack", "dependencies": { From 9192adbdbd966bd53d7f19bacf565362557e7689 Mon Sep 17 00:00:00 2001 From: zhangyaochun Date: Wed, 22 Jun 2016 13:35:14 +0800 Subject: [PATCH 09/15] [fix] removeStyleTypeAttributes is not supported change to removeStyleLinkTypeAttributes for removeStyleTypeAttributes is never used in [html-minifier](https://github.com/kangax/html-minifier) --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 3cc45634..7eae28f1 100644 --- a/index.js +++ b/index.js @@ -75,7 +75,7 @@ module.exports = function(content) { "useShortDoctype", "keepClosingSlash", "removeScriptTypeAttributes", - "removeStyleTypeAttributes" + "removeStyleLinkTypeAttributes" ].forEach(function(name) { if(typeof minimizeOptions[name] === "undefined") { minimizeOptions[name] = true; From 4e12d69dae1102153ab3354b5e042323dafb09b0 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 22 Jun 2016 13:10:48 -0400 Subject: [PATCH 10/15] bump deps --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index b6eca857..f1da65e4 100644 --- a/package.json +++ b/package.json @@ -6,13 +6,13 @@ "dependencies": { "es6-templates": "^0.2.2", "fastparse": "^1.0.0", - "html-minifier": "^1.4.0", - "loader-utils": "~0.2.2", - "object-assign": "^4.0.1" + "html-minifier": "^2.1.5", + "loader-utils": "^0.2.15", + "object-assign": "^4.1.0" }, "devDependencies": { "mocha": "^2.3.4", - "should": "^7.1.1" + "should": "^9.0.2" }, "scripts": { "test": "mocha --reporter spec" From 20040d667f15ec6a35a52e5a43417d4b9d137cc2 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 22 Jun 2016 13:10:59 -0400 Subject: [PATCH 11/15] 1.2.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f1da65e4..a160ba3f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-html-loader", - "version": "1.2.2", + "version": "1.2.3", "author": "Evan You", "description": "vue template loader for webpack", "dependencies": { From 3cdc41e774be39da48faf403d1addf16c92510a5 Mon Sep 17 00:00:00 2001 From: Till Sanders Date: Fri, 21 Oct 2016 16:34:39 +0200 Subject: [PATCH 12/15] Update package.json license reference Scheme has changed. For example: running `npm view vue-html-loader license` in terminal returns `undefined` instead of `MIT`. See the docs for further information: https://docs.npmjs.com/files/package.json#license --- package.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/package.json b/package.json index a160ba3f..81eb2fd3 100644 --- a/package.json +++ b/package.json @@ -21,10 +21,5 @@ "type": "git", "url": "git@github.com:vuejs/vue-html-loader.git" }, - "licenses": [ - { - "type": "MIT", - "url": "http://www.opensource.org/licenses/mit-license.php" - } - ] + "license": "MIT" } From 86d7049c7ecd0a732d63c4f75d3516c03cac30f6 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Fri, 24 Feb 2017 11:42:07 +0900 Subject: [PATCH 13/15] fix deprecated warning --- index.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 7eae28f1..c111f499 100644 --- a/index.js +++ b/index.js @@ -14,7 +14,7 @@ function randomIdent() { } function getLoaderConfig(context) { - var query = loaderUtils.parseQuery(context.query); + var query = loaderUtils.getOptions(context) || {}; var config = (context.options && context.options.vue && context.options.vue.html) || {}; delete query.config; return assign(query, config); diff --git a/package.json b/package.json index 81eb2fd3..7d07babb 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "es6-templates": "^0.2.2", "fastparse": "^1.0.0", "html-minifier": "^2.1.5", - "loader-utils": "^0.2.15", + "loader-utils": "^1.0.2", "object-assign": "^4.1.0" }, "devDependencies": { From 1f834083738e9dadd9928bf8699222a878a481f7 Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 23 Feb 2017 22:30:02 -0500 Subject: [PATCH 14/15] 1.2.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7d07babb..3c0199a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-html-loader", - "version": "1.2.3", + "version": "1.2.4", "author": "Evan You", "description": "vue template loader for webpack", "dependencies": { From 205b0b6495ab45ad0bc309c2728552afde9633b6 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 6 Jan 2018 10:27:21 -0500 Subject: [PATCH 15/15] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 09e819e0..97ca5480 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +# DEPRECATED + +This is only used by the now outdated 8.x version of vue-loader. + +--- + # vue-html-loader > This is a fork of [html-loader](https://github.com/webpack/html-loader) with some modifications for handling Vue templates. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy