-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwebpack.config.js
More file actions
39 lines (37 loc) · 1.11 KB
/
webpack.config.js
File metadata and controls
39 lines (37 loc) · 1.11 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
var fs = require('fs');
var path = require('path');
var EXAMPLES_DIR = path.resolve(process.cwd(), 'examples');
function buildEntries() {
return fs.readdirSync(EXAMPLES_DIR).reduce(function (entries, dir) {
if (dir === 'build') return entries;
var isDraft = dir.charAt(0) === '_';
var isDirectory = fs.lstatSync(path.join(EXAMPLES_DIR, dir)).isDirectory();
if (!isDraft && isDirectory) {
entries[dir] = path.join(EXAMPLES_DIR, dir, 'app.js');
}
return entries;
}, {});
}
module.exports = {
entry: buildEntries(),
output: {
filename: '[name].js',
chunkFilename: '[id].chunk.js',
path: path.resolve(process.cwd(), 'examples/__build__'),
publicPath: '/__build__/'
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
module: {
rules: [
{ test: /\.jpg/, use: 'url-loader' },
{ test: /\.css$/, use: ['style-loader', 'css-loader'] },
{ test: /\.tsx?$/, exclude: /node_modules/, use: 'ts-loader' },
{ test: /\.js$/, exclude: /node_modules/, use: 'babel-loader' },
]
},
optimization: {
splitChunks: { chunks: 'all', name: 'shared' },
}
};