This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
72 lines (68 loc) · 1.8 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
/*jslint node: true */
'use strict';
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
var CompressionPlugin = require("compression-webpack-plugin");
const webpack = require('webpack');
const path = require('path');
module.exports = {
// entry: 'app/main.ts',
output: {
filename: 'bundle.js'
//path: './dist'
},
// devtool: 'source-map',
devtool: 'cheap-module-source-map',
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: ['.webpack.js', '.web.js', '.ts', '.tsx', '.js'],
alias: {
app: path.resolve(__dirname, 'app')
}
},
module: {
rules: [
// all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
{ test: /\.tsx?$/, loader: 'ts-loader' },
{
test: /app\/.+\.ts$/,
exclude: /(node_modules|\.spec\.ts$)/,
loader: 'istanbul-instrumenter-loader',
enforce: 'post'
},
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' },
{
test: /\.s?css$/,
loaders: ['to-string-loader', 'css-loader', 'sass-loader']
},
{ test: /\.html$/, loader: 'html-loader' }
]
},
plugins: [
/*
new BundleAnalyzerPlugin({
defaultSizes: 'stat'
//defaultSizes: 'parsed' // not yet supported
//defaultSizes: 'gzip' // not yet supported
}),
*/
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
// Tree shake and compress
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
output: {
comments: false
},
sourceMap: false
}),
new CompressionPlugin({
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.js$|\.html$/,
threshold: 10240,
minRatio: 0.8
}),
],
watch: true
};