From 94e511bb962d05ef1863268ad3ccab2df2b540f9 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Tue, 13 Feb 2018 17:28:47 -0500 Subject: [PATCH] Further improvements to page prerendering --- src/pages/404/config.js | 3 +++ src/pages/index/config.js | 3 +++ src/template.html | 6 +++--- webpack.common.js | 16 ++++++++++------ 4 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 src/pages/404/config.js create mode 100644 src/pages/index/config.js diff --git a/src/pages/404/config.js b/src/pages/404/config.js new file mode 100644 index 0000000..418eef5 --- /dev/null +++ b/src/pages/404/config.js @@ -0,0 +1,3 @@ +module.exports = { + title: 'Regexper - Page Not Found' +}; diff --git a/src/pages/index/config.js b/src/pages/index/config.js new file mode 100644 index 0000000..94cc300 --- /dev/null +++ b/src/pages/index/config.js @@ -0,0 +1,3 @@ +module.exports = { + title: 'Regexper' +}; diff --git a/src/template.html b/src/template.html index 9c0e4e7..ec7d933 100644 --- a/src/template.html +++ b/src/template.html @@ -3,13 +3,13 @@ - + - Regexper + <%= htmlWebpackPlugin.options.title %> - +
diff --git a/webpack.common.js b/webpack.common.js index 88cf3fd..b6f8074 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -7,9 +7,16 @@ const FaviconsPlugin = require('favicons-webpack-plugin-cesco'); const HtmlPlugin = require('html-webpack-plugin'); const pkg = require('./package.json'); +const buildId = [ + process.env.CIRCLE_BRANCH || 'prerelease', + process.env.CIRCLE_BUILD_NUM || '##', + (process.env.CIRCLE_SHA1 || 'gitsha').slice(0, 7) +].join('-'); const pages = fs.readdirSync(path.resolve(__dirname, 'src/pages')); const pagePlugins = pages.map(name => new HtmlPlugin({ + description: pkg.description, + buildId, template: './src/template.html', filename: `${ name }.html`, chunks: ['common', name], @@ -23,7 +30,8 @@ const pagePlugins = pages.map(name => new HtmlPlugin({ minifyJS: true, minifyCSS: true, minifyURLs: true - } + }, + ...require(`./src/pages/${ name }/config`) })); module.exports = { @@ -42,11 +50,7 @@ module.exports = { GA_PROPERTY: null, SENTRY_KEY: null, BANNER: process.env.NODE_ENV === 'production' ? null : (process.env.NODE_ENV || 'development'), - BUILD_ID: [ - process.env.CIRCLE_BRANCH || 'prerelease', - process.env.CIRCLE_BUILD_NUM || '##', - (process.env.CIRCLE_SHA1 || 'gitsha').slice(0, 7) - ].join('-') + BUILD_ID: buildId }), new webpack.optimize.CommonsChunkPlugin({ name: 'common',