forked from kryton/hue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.workers.js
80 lines (75 loc) · 3.02 KB
/
webpack.config.workers.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
const webpack = require('webpack');
const BundleTracker = require('webpack-bundle-tracker');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CleanObsoleteChunks = require('webpack-clean-obsolete-chunks');
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',
target: 'webworker',
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: {
sqlLocationWebWorker: ['./desktop/core/src/desktop/js/sql/sqlLocationWebWorker.js'],
sqlSyntaxWebWorker: ['./desktop/core/src/desktop/js/sql/sqlSyntaxWebWorker.js']
},
optimization: {
minimize: true
},
output: {
path: __dirname + '/desktop/core/src/desktop/static/desktop/js/bundles/workers',
filename: '[name]-bundle-[hash].js',
chunkFilename: '[name]-chunk-[hash].js',
globalObject: 'this'
},
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'
},
{ include: /\.json$/, loaders: ['json-loader'] }
]
},
plugins: [
new CleanObsoleteChunks(),
new CleanWebpackPlugin([
__dirname + '/desktop/core/src/desktop/static/desktop/js/bundles/workers/'
]),
new RelativeBundleTracker({ path: '.', filename: 'webpack-stats-workers.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'
)
]
};