-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.examples.js
45 lines (36 loc) · 1.09 KB
/
webpack.config.examples.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
'use strict';
var fs = require('fs');
var path = require('path');
var zipObject = require('lodash.zipobject');
var EXAMPLES_BASE_DIR = path.join(__dirname, 'examples');
var getDirectories = function(srcPath) {
return fs.readdirSync(srcPath).filter(function(file) {
return fs.statSync(path.join(srcPath, file)).isDirectory() &&
file.indexOf('_') !== 0;
});
};
var makeFullPath = function(p) {
return path.join(EXAMPLES_BASE_DIR, p);
};
var makeAppPath = function(dir) {
return path.join(dir, 'app.js');
};
var examplesNames = getDirectories(EXAMPLES_BASE_DIR);
var examplesPaths = examplesNames.map(makeFullPath);
var examplesAppPaths = examplesPaths.map(makeAppPath);
var entry = zipObject(examplesNames, examplesAppPaths);
var modulesDirectories = ['node_modules', 'src'];
modulesDirectories = modulesDirectories.concat(examplesPaths);
module.exports = {
entry: entry,
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
},
resolve: {
alias: {
bazooka: path.join(__dirname, 'src', 'main.js'),
},
modules: modulesDirectories,
},
};