forked from SilverHoodCorp/polar-bookshelf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
128 lines (109 loc) · 3.91 KB
/
Copy pathwebpack.config.js
File metadata and controls
128 lines (109 loc) · 3.91 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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
const path = require('path');
const webpack = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
var ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const workers = require('os').cpus().length - 1;
console.log("Using N workers: " + workers);
module.exports = {
// mode: 'development',
entry: {
// chrome + repository (individually) is about:
//
// 10.2MB raw
// 3.1MB compressed
// (2.4MB with brotli / 22% smaller)
//
// chrome + repository (both) is about
// 5.1MB raw and about
// 1.6MB compressed.
"chrome": [ "./web/js/apps/chrome.ts"],
"repository": [ "./apps/repository/js/entry.tsx"],
"login": [ "./apps/repository/js/login.ts"],
"add-shared-doc": [ "./apps/add-shared-doc/js/index.ts"],
// "all": [ "./web/js/apps/chrome.ts", "./apps/repository/js/entry.tsx", "./apps/repository/js/login.ts"],
// "both": [ "./web/js/apps/chrome.ts", "./apps/repository/js/entry.tsx"],
},
module: {
rules: [
// https://github.com/webpack-contrib/cache-loader
//
// looks like with the cache loader the initial compile is about 10%
// longer but 2x faster once the cache is running.
{ loader: 'cache-loader' },
{
test: path.resolve(__dirname, 'node_modules/electron/index.js'),
use: 'null-loader'
},
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'thread-loader',
options: {
// there should be 1 cpu for the fork-ts-checker-webpack-plugin
workers: 15,
// set this to Infinity in watch mode - see https://github.com/webpack-contrib/thread-loader
poolTimeout: Infinity,
workerParallelJobs: 100,
poolTimeout: 2000,
}
},
{
loader: 'ts-loader',
options: {
// performance: this improved performance by about 2x.
// from 20s to about 10s
transpileOnly: true,
experimentalWatchApi: true,
// IMPORTANT! use happyPackMode mode to speed-up
// compilation and reduce errors reported to webpack
happyPackMode: true
}
}
]
}
]
},
resolve: {
extensions: [ '.tsx', '.ts', '.js' ]
},
// only inline-source-map works.
// devtool: "inline-source-map",
output: {
path: path.resolve(__dirname, 'web/dist'),
filename: '[name]-bundle.js',
// publicPath: '/web/js/apps'
},
node: {
//needed to make webpack work on chrome
fs: 'empty',
net: 'empty',
tls: 'empty',
},
plugins: [
// new BundleAnalyzerPlugin(),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.$": "jquery",
"window.jQuery": "jquery"
}),
new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true })
],
optimization: {
minimize: true,
usedExports: true,
removeAvailableModules: false,
removeEmptyChunks: false,
splitChunks: false,
},
devServer: {
publicPath: 'web/dist',
contentBase: path.join(__dirname, '.'),
compress: true,
port: 443,
watchContentBase: true,
host: 'localapp.getpolarized.io'
}
};