-
Notifications
You must be signed in to change notification settings - Fork 463
/
webpack.config.js
68 lines (59 loc) · 1.33 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
function ExamplesPlugin() {}
ExamplesPlugin.prototype.apply = function (compiler) {
compiler.resolvers.normal.plugin('module', function(request, callback) {
if(request.request === 'examples') {
this.doResolve('module', { path: '', request: '' }, function () {
callback(null, {
path: path.join(__dirname, 'index.js'),
query: '?examples',
resolved: true
});
});
} else {
callback();
}
});
};
module.exports = {
entry: path.join(__dirname, 'index.js'),
output: {
path: './playground',
filename: 'bundle.js',
publicPath: '/'
},
devServer: {
filename: 'index.js',
contentBase: './playground'
},
devtool: 'source-map',
resolveLoader: {
alias: {
'examples-loader': path.join(__dirname, 'examples-loader')
}
},
resolve: {
root: path.join(__dirname, '..', 'src'),
alias: {
'react-desktop': path.join(__dirname, '..', 'src')
}
},
module: {
loaders: [
{
test: /\?examples/,
loaders: ['babel', 'examples-loader']
},
{
test: /\.(js)$/,
exclude: /node_modules/,
loader: 'babel'
}
]
},
plugins: [
new HtmlWebpackPlugin(),
new ExamplesPlugin()
]
};