forked from kryton/hue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
86 lines (81 loc) · 3.2 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const webpack = require('webpack');
const BundleTracker = require('webpack-bundle-tracker');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CleanObsoleteChunks = require('webpack-clean-obsolete-chunks');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const path = require('path');
const each = require('lodash/fp/each');
// https://github.com/ezhome/webpack-bundle-tracker/issues/25
class RelativeBundleTracker extends BundleTracker {
convertPathChunks(chunks) {
each(
each(chunk => {
chunk.path = path.relative(this.options.path, chunk.path);
})
)(chunks);
}
writeOutput(compiler, contents) {
if (contents.status === 'done') {
this.convertPathChunks(contents.chunks);
}
super.writeOutput(compiler, contents);
}
}
module.exports = {
devtool: 'source-map',
mode: 'development',
performance: {
maxEntrypointSize: 400 * 1024, // 400kb
maxAssetSize: 400 * 1024 // 400kb
},
resolve: {
extensions: ['.json', '.jsx', '.js'],
modules: ['node_modules', 'js'],
alias: {
bootstrap: __dirname + '/node_modules/bootstrap-2.3.2/js'
}
},
entry: {
hue: ['./desktop/core/src/desktop/js/hue.js'],
notebook: ['./desktop/core/src/desktop/js/apps/notebook/app.js'],
tableBrowser: ['./desktop/core/src/desktop/js/apps/table_browser/app.js']
},
optimization: {
//minimize: true,
minimize: false,
splitChunks: {
chunks: 'all',
automaticNameMaxLength: 90
},
runtimeChunk: {
name: 'hue'
}
},
output: {
path: __dirname + '/desktop/core/src/desktop/static/desktop/js/bundles/hue',
filename: '[name]-bundle-[hash].js',
chunkFilename: '[name]-chunk-[hash].js'
},
module: {
rules: [
{ test: /\.(html)$/, loader: 'html?interpolate&removeComments=false' },
{ test: /\.less$/, loader: 'style-loader!css-loader!less-loader' },
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{ test: /\.(woff2?|ttf|eot|svg)$/, loader: 'file-loader' },
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
}
]
},
plugins: [
// new BundleAnalyzerPlugin({ analyzerPort: 9000 }),
new CleanObsoleteChunks(),
new CleanWebpackPlugin([__dirname + '/desktop/core/src/desktop/static/desktop/js/bundles/hue']),
new RelativeBundleTracker({ path: '.', filename: 'webpack-stats.json' }),
new webpack.BannerPlugin(
'\nLicensed to Cloudera, Inc. under one\nor more contributor license agreements. See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership. Cloudera, Inc. licenses this file\nto you under the Apache License, Version 2.0 (the\n"License"); you may not use this file except in compliance\nwith the License. You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an "AS IS" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n'
)
]
};