diff --git a/index.js b/index.js index e1d785d..12b3826 100644 --- a/index.js +++ b/index.js @@ -25,15 +25,16 @@ HtmlWebpackInlineSourcePlugin.prototype.apply = function (compiler) { } var regexStr = htmlPluginData.plugin.options.inlineSource; + var nonceTemplateStr = htmlPluginData.plugin.options.nonceTemplate; - var result = self.processTags(compilation, regexStr, htmlPluginData); + var result = self.processTags(compilation, regexStr, htmlPluginData, nonceTemplateStr); callback(null, result); }); }); }; -HtmlWebpackInlineSourcePlugin.prototype.processTags = function (compilation, regexStr, pluginData) { +HtmlWebpackInlineSourcePlugin.prototype.processTags = function (compilation, regexStr, pluginData, nonceTemplateStr) { var self = this; var body = []; @@ -42,11 +43,11 @@ HtmlWebpackInlineSourcePlugin.prototype.processTags = function (compilation, reg var regex = new RegExp(regexStr); pluginData.head.forEach(function (tag) { - head.push(self.processTag(compilation, regex, tag)); + head.push(self.processTag(compilation, regex, tag, nonceTemplateStr)); }); pluginData.body.forEach(function (tag) { - body.push(self.processTag(compilation, regex, tag)); + body.push(self.processTag(compilation, regex, tag, nonceTemplateStr)); }); return { head: head, body: body, plugin: pluginData.plugin, chunks: pluginData.chunks, outputName: pluginData.outputName }; @@ -83,7 +84,7 @@ HtmlWebpackInlineSourcePlugin.prototype.resolveSourceMaps = function (compilatio }); }; -HtmlWebpackInlineSourcePlugin.prototype.processTag = function (compilation, regex, tag) { +HtmlWebpackInlineSourcePlugin.prototype.processTag = function (compilation, regex, tag, nonceTemplateStr) { var assetUrl; // inline js @@ -97,6 +98,10 @@ HtmlWebpackInlineSourcePlugin.prototype.processTag = function (compilation, rege } }; + if (nonceTemplateStr) { + tag.attributes.nonce = nonceTemplateStr; + } + // inline css } else if (tag.tagName === 'link' && regex.test(tag.attributes.href)) { assetUrl = tag.attributes.href; diff --git a/package.json b/package.json index a679825..e687c8b 100644 --- a/package.json +++ b/package.json @@ -1,20 +1,19 @@ { - "name": "html-webpack-inline-source-plugin", - "version": "0.0.10", + "name": "@postmates/html-webpack-inline-source-plugin", + "version": "0.0.10-pm1", "description": "Embed javascript and css source inline when using the webpack dev server or middleware", "main": "index.js", "files": [ "index.js" ], "scripts": { - "prepublish": "npm run test", "pretest": "semistandard", "test": "jasmine", "debug": "node-debug jasmine" }, "repository": { "type": "git", - "url": "https://github.com/dustinjackson/html-webpack-inline-source-plugin.git" + "url": "git+https://github.com/postmates/html-webpack-inline-source-plugin.git" }, "keywords": [ "webpack",