forked from wagtail/wagtail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.base.config.js
68 lines (58 loc) · 1.49 KB
/
webpack.base.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var _ = require('lodash');
var path = require('path');
var glob = require('glob').sync;
var webpack = require('webpack');
var COMMON_PATH = './wagtail/wagtailadmin/static/wagtailadmin/js/common.js';
function appName(filename) {
return _(filename)
.split(path.sep)
.get(2);
}
function entryPoint(filename) {
var name = appName(filename);
var entryName = path.basename(filename, '.entry.js');
var outputPath = path.join('wagtail', name, 'static', name, 'js', entryName);
return [outputPath, filename];
}
function entryPoints(paths) {
return _(glob(paths))
.map(entryPoint)
.fromPairs()
.value();
}
module.exports = function exports() {
var CLIENT_DIR = path.resolve(__dirname, 'client', 'src');
return {
entry: entryPoints('./wagtail/**/static_src/**/app/*.entry.js'),
resolve: {
alias: {
config: path.resolve(CLIENT_DIR, 'config'),
components: path.resolve(CLIENT_DIR, 'components')
}
},
output: {
path: './',
filename: '[name].js',
publicPath: '/static/js/'
},
plugins: [
new webpack.ProvidePlugin({
fetch: 'imports?this=>global!exports?global.fetch!whatwg-fetch'
}),
new webpack.optimize.CommonsChunkPlugin('common', COMMON_PATH, Infinity)
],
devtool: '#inline-source-map',
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel'
},
{
test: /\.jsx$/,
loader: 'babel'
}
]
}
};
};