diff --git a/mustache-renderer-webpack-plugin/index.js b/mustache-renderer-webpack-plugin/index.js deleted file mode 100644 index 9e9df5faf..000000000 --- a/mustache-renderer-webpack-plugin/index.js +++ /dev/null @@ -1,50 +0,0 @@ -var defaults = require('lodash.defaults'); -var fs = require('fs'); -var mustache = require('mustache'); - -var render = function (template, route, config) { - config = config || {}; - // Route definition - defaults(route, config); - - // Render template - return mustache.render(template, route); -}; - -function MustacheRendererPlugin (options) { - if (!options.templatePath) throw new Error('MustacheRendererPlugin requires a templatePath option'); - // Read template - var template = fs.readFileSync(options.templatePath, 'utf8'); - this.template = template; - this.routes = options.routes || {}; - this.config = options.config || {}; - return this; -} - -MustacheRendererPlugin.prototype.apply = function (compiler) { - var template = this.template; - var config = this.config; - var routes = this.routes; - - compiler.plugin('emit', function (compilation, callback) { - var outputRoutes = {}; - routes.forEach(function (route) { - var filename = route.name + '.html'; - var content = render(template, route, config); - outputRoutes[route.pattern] = filename; - compilation.assets[filename] = { - source: function () {return content;}, - size: function () {return content.length;} - }; - }); - var routeJson = JSON.stringify(outputRoutes); - compilation.assets['routes.json'] = { - source: function () {return routeJson;}, - size: function () {return routeJson.length;} - }; - callback(); - }); -}; - -module.exports = MustacheRendererPlugin; - diff --git a/package.json b/package.json index a9f0916aa..6951df6b2 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "express": "4.13.4", "express-http-proxy": "0.6.0", "lodash.defaults": "4.0.1", - "mustache": "2.2.1", "newrelic": "1.25.4", "raven": "0.10.0" }, @@ -53,6 +52,7 @@ "git-bundle-sha": "0.0.2", "glob": "5.0.15", "google-libphonenumber": "1.0.21", + "html-webpack-plugin": "2.22.0", "iso-3166-2": "0.4.0", "json-loader": "0.5.2", "json2po-stream": "1.0.3", diff --git a/src/template.html b/src/template.html index 9f905045a..440e3de6e 100644 --- a/src/template.html +++ b/src/template.html @@ -6,25 +6,25 @@ - + - Scratch - {{title}} + Scratch - <%= htmlWebpackPlugin.options.config.title %> - + - - - - - - + + + + + + @@ -40,7 +40,7 @@ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - ga('create', '{{&ga_tracker}}', { + ga('create', '<%- htmlWebpackPlugin.options.config.ga_tracker %>', { 'sampleRate': 10 }); ga('send', 'pageview'); @@ -51,11 +51,11 @@
- + - - + +