-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
53 lines (48 loc) · 1.38 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const webpack = require('webpack');
const StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin');
const extract = Boolean(process.env.WP_EXTRACT);
const locale = process.env.WP_LOCALE;
const HOST = process.env.HOST || 'http://127.0.0.1:8000';
const path = require('path');
const c3poConfig = {
extract: extract ? { output: 'dist/translations.pot' } : null,
};
if (locale) {
c3poConfig.resolve = { translations: `i18n/${locale}.po` };
}
const babelConfig = {
presets: [['es2015', {modules: false}], 'react'],
plugins: [['c-3po', c3poConfig]]
};
function localePath(path) {
return (!locale) ? path : `${locale}/${path}`;
}
module.exports = {
entry: {
index: './src/index.js'
},
output: {
path: path.join(__dirname, './docs'),
filename: localePath('build.js'),
libraryTarget: 'umd'
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: babelConfig
},
]
},
plugins: [
new StaticSiteGeneratorPlugin('index', localePath('index.html')),
new webpack.DefinePlugin({
HOST: JSON.stringify(HOST),
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
}
}),
]
};