From 611389c9d064b5e93b8a0832b255e29902ccc866 Mon Sep 17 00:00:00 2001 From: Marshall Quander <marshall@quander.me> Date: Thu, 26 Jul 2018 19:27:30 -0700 Subject: [PATCH] Inject origin trial data into HTML more cleanly --- package.json | 1 - src/hub.html | 1 - webpack.config.js | 40 ++++++++++------------------------------ 3 files changed, 10 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index f31e683cd..1f52f03e5 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,6 @@ "html-loader": "^0.5.5", "html-webpack-plugin": "^3.1.0", "htmlhint": "^0.9.13", - "lodash": "^4.17.5", "node-sass": "^4.7.2", "prettier": "^1.7.0", "rimraf": "^2.6.2", diff --git a/src/hub.html b/src/hub.html index 9c7db93b0..cdc64e069 100644 --- a/src/hub.html +++ b/src/hub.html @@ -5,7 +5,6 @@ <!-- DO NOT REMOVE/EDIT THIS COMMENT - HUB_META_TAGS --> <meta charset="utf-8"> - <meta http-equiv="origin-trial" data-feature="WebVR (For Chrome M62+)" data-expires="<%= ORIGIN_TRIAL_EXPIRES %>" content="<%= ORIGIN_TRIAL_TOKEN %>"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <link rel="shortcut icon" type="image/png" href="/favicon.ico"> diff --git a/webpack.config.js b/webpack.config.js index 5cb651c3a..8331426dd 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -9,7 +9,6 @@ const HTMLWebpackPlugin = require("html-webpack-plugin"); const ExtractTextPlugin = require("extract-text-webpack-plugin"); const CopyWebpackPlugin = require("copy-webpack-plugin"); const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); -const _ = require("lodash"); function createHTTPSConfig() { // Generate certs for the local webpack-dev-server. @@ -58,21 +57,6 @@ function createHTTPSConfig() { } } -class LodashTemplatePlugin { - constructor(options) { - this.options = options; - } - - apply(compiler) { - compiler.plugin("compilation", compilation => { - compilation.plugin("html-webpack-plugin-before-html-processing", async data => { - data.html = _.template(data.html, this.options)(); - return data; - }); - }); - } -} - module.exports = (env, argv) => ({ entry: { index: path.join(__dirname, "src", "index.js"), @@ -118,9 +102,7 @@ module.exports = (env, argv) => ({ loader: "html-loader", options: { // <a-asset-item>'s src property is overwritten with the correct transformed asset url. - attrs: ["img:src", "a-asset-item:src", "audio:src", "source:src"], - // You can get transformed asset urls in an html template using ${require("pathToFile.ext")} - interpolate: "require" + attrs: ["img:src", "a-asset-item:src", "audio:src", "source:src"] } }, { @@ -219,7 +201,15 @@ module.exports = (env, argv) => ({ filename: "hub.html", template: path.join(__dirname, "src", "hub.html"), chunks: ["vendor", "engine", "hub"], - inject: "head" + inject: "head", + meta: [ + { + "http-equiv": "origin-trial", + "data-feature": "WebVR (For Chrome M62+)", + "data-expires": process.env.ORIGIN_TRIAL_EXPIRES, + "data-content": process.env.ORIGIN_TRIAL_TOKEN + } + ] }), new HTMLWebpackPlugin({ filename: "link.html", @@ -249,16 +239,6 @@ module.exports = (env, argv) => ({ filename: "assets/stylesheets/[name]-[md5:contenthash:hex:20].css", disable: argv.mode !== "production" }), - // Transform the output of the html-loader using _.template - // before passing the result to html-webpack-plugin - new LodashTemplatePlugin({ - // expose these variables to the lodash template - // ex: <%= ORIGIN_TRIAL_TOKEN %> - imports: { - ORIGIN_TRIAL_EXPIRES: process.env.ORIGIN_TRIAL_EXPIRES, - ORIGIN_TRIAL_TOKEN: process.env.ORIGIN_TRIAL_TOKEN - } - }), // Define process.env variables in the browser context. new webpack.DefinePlugin({ "process.env": JSON.stringify({ -- GitLab