Use thumbnail image host from process.env

Limit built process.env to keys in src/env.json, which serves as a source for defaults.
This commit is contained in:
Ray Schamp 2015-10-02 18:24:44 -04:00
parent f811cf82af
commit 446543c6c4
3 changed files with 11 additions and 1 deletions

View file

@ -33,7 +33,7 @@ module.exports = React.createClass({
<Slider className={'carousel ' + this.props.className} {... this.props.settings}>
{this.props.items.map(function (item) {
var thumbnailUrl = (
'//cdn2.scratch.mit.edu/get_image/' + item.type + '/' + item.id + '_' +
process.env.IMAGE_HOST + '/get_image/' + item.type + '/' + item.id + '_' +
this.typeDimensions[item.type][0] + 'x' + this.typeDimensions[item.type][1] + '.png' +
'?v=' + item.thumbnailVersion
);

3
src/env.json Normal file
View file

@ -0,0 +1,3 @@
{
"IMAGE_HOST": "//cdn2.scratch.mit.edu"
}

View file

@ -1,6 +1,7 @@
var path = require('path');
var webpack = require('webpack');
var routes = require('./server/routes.json');
var buildEnv = require('./src/env.json');
// Prepare all entry points
var entry = {
@ -48,6 +49,12 @@ module.exports = {
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': Object.keys(buildEnv).reduce(function (env, key) {
env[key] = JSON.stringify(process.env[key] || env[key]);
return env;
}, buildEnv)
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false