-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathwebpack.config.js
120 lines (109 loc) · 3.69 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
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
const path = require('path');
const webpack = require('webpack');
const CompressionPlugin = require('compression-webpack-plugin');
const optionDefinitions = [
{ name: 'verbose', alias: 'v', type: Boolean },
{ name: 'src', type: String, multiple: true, defaultOption: true },
{ name: 'timeout', alias: 't', type: Number },
{ name: 'mode', type: String, defaultOption: 'unknown' },
{ name: 'analyze', type: Boolean, defaultOption: false },
{ name: 'watch', type: Boolean},
];
const commandLineArgs = require('command-line-args');
const options = commandLineArgs(
optionDefinitions,
{partial: false}
);
const TimestampWebpackPlugin = require('timestamp-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = {
devtool: 'source-map',
entry: {
app: [
'./public/tsx/bootstrap.tsx',
]
// ,
// vendor: [
// 'react',
// 'react-dom'
// ]
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
loader: 'ts-loader'
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader"
}
]
},
optimization: {
splitChunks: {
cacheGroups: {
default: false,
vendors: false,
}
}
},
output: {
path: path.resolve(__dirname, 'public/js'),
filename: '[name].bundle.js'
},
performance: {
hints: false,
// hints: process.env.NODE_ENV === 'production' ? "warning" : false
},
plugins: [
// new HtmlWebpackPlugin({ template: path.resolve(__dirname, 'src', 'app', 'index.html') }),
// new webpack.HotModuleReplacementPlugin()
// new TimestampWebpackPlugin({
// path: path.join(__dirname, 'public/dist'),
// // default output is timestamp.json
// filename: 'timestamp.json'
// }),
new BundleAnalyzerPlugin({
analyzerHost: "0.0.0.0",
//analyzerMode: options.analyze === "enabled" ? 'static': "server",
analyzerMode: 'static',
openAnalyzer: false
}),
new CompressionPlugin(),
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
// new webpack.ProvidePlugin({
// $: "jquery",
// jQuery: "jquery",
// "window.jQuery": "jquery"
// })
],
resolve: {
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
"alias": {
"react": "preact/compat",
"react-dom/test-utils": "preact/test-utils",
"react-dom": "preact/compat",
// 'react-dom': __dirname + '/node_modules/preact-compat',
'react-addons-css-transition-group': __dirname + '/node_modules/rc-css-transition-group',
'react-addons-shallow-compare': __dirname + '/node_modules/preact-shallow-compare',
'react-color': __dirname + '/node_modules/react-color',
// 'react': __dirname + '/node_modules/preact-compat',
}
},
// // When importing a module whose path matches one of the following, just
// // assume a corresponding global variable exists and use that instead.
// // This is important because it allows us to avoid bundling all of our
// // dependencies, which allows browsers to cache those libraries between builds.
// externals: {
// "react": "React",
// "react-dom": "ReactDOM"
// }
};