-
Notifications
You must be signed in to change notification settings - Fork 25
/
webpack.config.js
56 lines (52 loc) · 1.57 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
const path = require('path');
var fs = require("fs");
var webpack = require("webpack");
const PATHS = {
dashboards: path.join(__dirname, 'dashboards'),
build: path.join(__dirname, 'build'),
jobs: path.join(__dirname, 'jobs'),
widgets: path.join(__dirname, 'widgets'),
styles: path.join(__dirname, 'styles')
};
// grab all dashboards
var dashboardPaths = fs.readdirSync(PATHS.dashboards).reduce(function(map, filename) {
map[path.basename(filename, '.jsx')] = path.join(PATHS.dashboards, filename);
return map;
}, {});
var webConfig = {
entry: dashboardPaths,
target: 'web',
output: { path: PATHS.build, filename: '[name].dashboard.bundle.js'},
module: {
rules: [
{
test: /\.(js|jsx)$/,
use: {
loader: 'babel-loader',
// Enable caching for improved performance during development
// It uses default OS directory by default. If you need something
// more custom, pass a path to it. I.e., babel?cacheDirectory=<path>
options: {cacheDirectory: true}
},
include: [PATHS.dashboards, PATHS.widgets],
},
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
include: [PATHS.styles, PATHS.widgets]
}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({name: 'commons', filename: 'common.bundle.js'}),
new webpack.EnvironmentPlugin({"NODE_ENV": 'development'})
],
resolve: {
extensions: ['.js', '.jsx', '.scss'],
modules: [
path.resolve(__dirname),
'node_modules'
]
}
};
module.exports = webConfig