2015-12-20 15:19:50 -08:00
|
|
|
var webpack = require('webpack');
|
2016-01-22 17:43:40 -08:00
|
|
|
var path = require('path');
|
|
|
|
var fs = require('fs');
|
|
|
|
|
2017-02-16 10:21:04 -08:00
|
|
|
const defaultLocale = "en-GB";
|
|
|
|
var locale = process.env.locale || defaultLocale;
|
|
|
|
|
|
|
|
console.log("Using locale: "+locale);
|
|
|
|
|
2016-01-09 18:39:09 -08:00
|
|
|
// Bundle entry point
|
2015-12-20 15:19:50 -08:00
|
|
|
var entry = ['./components/App.jsx'];
|
2016-01-09 18:39:09 -08:00
|
|
|
|
2016-01-22 17:43:40 -08:00
|
|
|
// Bundle target
|
|
|
|
var target = "web";
|
|
|
|
|
|
|
|
// Bundle output
|
|
|
|
var output = {
|
|
|
|
path: __dirname,
|
|
|
|
filename: 'article.js'
|
|
|
|
};
|
2016-01-16 17:57:16 -08:00
|
|
|
|
2016-01-09 18:39:09 -08:00
|
|
|
// Necessary webpack loaders for converting our content:
|
|
|
|
var webpackLoaders = [
|
|
|
|
'babel-loader',
|
2017-02-13 17:27:52 -08:00
|
|
|
'eslint-loader',
|
2016-01-09 18:39:09 -08:00
|
|
|
__dirname + '/lib/latex-loader',
|
|
|
|
__dirname + '/lib/pre-loader',
|
2017-02-15 16:00:02 -08:00
|
|
|
__dirname + '/lib/p-loader',
|
|
|
|
__dirname + '/lib/textarea-loader'
|
2016-01-09 18:39:09 -08:00
|
|
|
];
|
|
|
|
|
2017-02-16 10:21:04 -08:00
|
|
|
var resolve = {
|
|
|
|
alias: {
|
|
|
|
LocalizedContent: path.resolve(__dirname, 'locales/en-GB/content.js')
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// switch the locales
|
|
|
|
if (locale !== defaultLocale) {
|
|
|
|
resolve = {
|
|
|
|
alias: {
|
|
|
|
LocalizedContent: path.resolve(__dirname, 'locales/' + locale + '/content.js')
|
|
|
|
}
|
|
|
|
};
|
|
|
|
output.filename = 'article.' + locale + '.js';
|
|
|
|
console.log("using " + resolve.alias.LocalizedContent + " for output " + output.filename);
|
|
|
|
}
|
2016-01-22 17:43:40 -08:00
|
|
|
|
2016-01-09 18:39:09 -08:00
|
|
|
// And the final config that webpack will read in.
|
2015-12-20 15:19:50 -08:00
|
|
|
module.exports = {
|
|
|
|
entry: entry,
|
2016-01-22 17:43:40 -08:00
|
|
|
target: target,
|
|
|
|
output: output,
|
2017-02-16 10:21:04 -08:00
|
|
|
resolve: resolve,
|
2015-12-20 15:19:50 -08:00
|
|
|
module: {
|
|
|
|
loaders: [
|
2016-01-22 17:43:40 -08:00
|
|
|
{
|
|
|
|
test: /\.(png|gif)$/,
|
|
|
|
loader: "file?name=images/packed/[hash].[ext]"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.less$/,
|
|
|
|
loader: "style!css!less"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.json$/,
|
|
|
|
loader: "json"
|
|
|
|
},
|
2015-12-20 15:19:50 -08:00
|
|
|
{
|
|
|
|
test: /.jsx?$/,
|
2016-01-22 17:43:40 -08:00
|
|
|
include: [
|
|
|
|
/components/,
|
2017-02-13 17:27:52 -08:00
|
|
|
/lib.site/,
|
|
|
|
/locales/
|
2016-01-22 17:43:40 -08:00
|
|
|
],
|
2016-01-09 18:39:09 -08:00
|
|
|
loaders: webpackLoaders
|
2015-12-20 15:19:50 -08:00
|
|
|
}
|
|
|
|
]
|
2017-02-15 16:00:02 -08:00
|
|
|
}
|
2015-12-23 08:08:32 -08:00
|
|
|
};
|