forked from reactjs/react-tabs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
45 lines (39 loc) · 1.07 KB
/
Copy pathwebpack.config.js
File metadata and controls
45 lines (39 loc) · 1.07 KB
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';
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const EXAMPLES_DIR = path.join(__dirname, 'examples');
function buildEntries() {
return fs.readdirSync(EXAMPLES_DIR).reduce(function(entries, dir) {
const isDraft = dir.charAt(0) === '_';
const isDirectory = fs.lstatSync(path.join(EXAMPLES_DIR, dir)).isDirectory();
const entryFile = path.join(EXAMPLES_DIR, dir, 'app.js');
if (!isDraft && isDirectory && fs.existsSync(entryFile)) {
entries[dir] = entryFile;
}
return entries;
}, {});
}
module.exports = {
entry: buildEntries(),
output: {
filename: '[name].js',
chunkFilename: '[id].chunk.js',
path: path.join(__dirname, 'examples/__build__'),
publicPath: '/__build__/',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
],
},
plugins: [new webpack.optimize.CommonsChunkPlugin({ name: 'shared' })],
};