This repository has been archived by the owner on Apr 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
85 lines (77 loc) · 1.87 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
const path = require('path');
const webpack = require('webpack');
const ExtractText = require('extract-text-webpack-plugin');
const Assets = require('assets-webpack-plugin');
const production = process.env.NODE_ENV === 'production';
const plugins = [
new webpack.LoaderOptionsPlugin({
minimize: production,
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(production ? 'production' : 'dev'),
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity,
}),
new ExtractText({ filename: '[name].[hash].css', allChunks: true }),
new Assets({
path: 'dist',
filename: 'assets.json',
prettyPrint: !production,
}),
];
const babelOptions = {
presets: [['es2015', { modules: false, loose: true }], 'stage-3'],
plugins: [['inferno', { imports: true }]],
};
if (production) {
plugins.push(new webpack.optimize.UglifyJsPlugin({
comments: false,
negate_iife: false, // <- for `v8LazyParse()`
comparisons: true,
conditionals: true,
dead_code: true,
evaluate: true,
if_return: true,
join_vars: true,
pure_getters: true,
unsafe: true,
unsafe_comps: true,
unused: true,
}));
}
module.exports = {
entry: {
bundle: './src/client/index.ts',
vendor: ['inferno', 'normalize.css'],
},
output: {
path: path.resolve(__dirname, 'dist/static'),
filename: '[name].[hash].js',
},
resolve: {
extensions: ['.js', '.ts', '.tsx'],
},
module: {
rules: [{
test: /tsx?$/,
use: [{
loader: 'babel-loader',
options: babelOptions,
}, {
loader: 'ts-loader',
}],
}, {
test: /\.css$/,
use: ExtractText.extract({
fallback: 'style-loader',
use: [{
loader: 'css-loader',
options: { modules: true },
}, 'postcss-loader'],
}),
}],
},
plugins,
};