24
1
Fork 0

added ver to qsurvey url

This commit is contained in:
Danny Coates 2017-12-05 12:45:36 -08:00
parent 28a7e0f717
commit 1849d712b1
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
3 changed files with 37 additions and 8 deletions

View File

@ -1,5 +1,16 @@
const html = require('choo/html');
const assets = require('../../common/assets');
/*
The current weback config uses package.json to generate
version.json for /__version__ meaning `require` returns the
string 'version.json' in the frontend context but the json
on the server.
We want `version` to be constant at build time so this file
has a custom loader (/build/version_loader.js) just to replace
string with the value from package.json. 🤢
*/
const version = require('../../package.json').version || 'VERSION';
module.exports = function(state) {
return html`<header class="header">
@ -14,8 +25,9 @@ module.exports = function(state) {
<div>${state.translate('siteSubtitle')}</div>
</div>
</div>
<a href="https://qsurvey.mozilla.com/s3/txp-firefox-send" rel="noreferrer noopener" class="feedback" target="_blank">${state.translate(
'siteFeedback'
)}</a>
<a href="https://qsurvey.mozilla.com/s3/txp-firefox-send?ver=${version}"
rel="noreferrer noopener"
class="feedback"
target="_blank">${state.translate('siteFeedback')}</a>
</header>`;
};

5
build/version_loader.js Normal file
View File

@ -0,0 +1,5 @@
const version = require('../package.json').version;
module.exports = function(source) {
return source.replace('VERSION', version);
};

View File

@ -4,6 +4,12 @@ const CopyPlugin = require('copy-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const IS_DEV = process.env.NODE_ENV === 'development';
const regularJSOptions = {
babelrc: false,
presets: [['env', { modules: false }], 'stage-2'],
plugins: ['yo-yoify']
};
module.exports = {
entry: {
vendor: ['babel-polyfill', 'fluent'],
@ -31,6 +37,16 @@ module.exports = {
}
]
},
{
include: require.resolve('./app/templates/header'),
use: [
{
loader: 'babel-loader',
options: regularJSOptions
},
'./build/version_loader'
]
},
{
include: [path.dirname(require.resolve('fluent'))],
use: [
@ -55,11 +71,7 @@ module.exports = {
path.resolve(__dirname, 'node_modules/fluent-intl-polyfill'),
path.resolve(__dirname, 'node_modules/intl-pluralrules')
],
options: {
babelrc: false,
presets: [['env', { modules: false }], 'stage-2'],
plugins: ['yo-yoify']
}
options: regularJSOptions
},
{
include: [path.resolve(__dirname, 'node_modules')],